local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local Players = game:GetService("Players")
local PathfindingService = game:GetService("PathfindingService")
local Config = {
MonsterName = "Slendytubby",
ModelName = "SlendytubbyModel",
MaxActive = 2,
SpawnInterval = 25,
ChaseRadius = 120,
AttackRange = 3,
Damage = 25,
WalkSpeed = 16,
RunSpeed = 28
}
local RemoteFolder = ReplicatedStorage:FindFirstChild("SlendyRemote") or
[Link]("Folder")
[Link] = "SlendyRemote"
[Link] = ReplicatedStorage
local NotifyEvent = RemoteFolder:FindFirstChild("Notify") or
[Link]("RemoteEvent")
[Link] = "Notify"
[Link] = RemoteFolder
local function getNearestPlayer(pos)
local nearestPlayer = nil
local nearestDist = [Link]
for _, player in ipairs(Players:GetPlayers()) do
if [Link] and
[Link]:FindFirstChild("HumanoidRootPart") then
local dist = ([Link] -
pos).Magnitude
if dist < nearestDist then
nearestDist = dist
nearestPlayer = player
end
end
end
return nearestPlayer, nearestDist
end
local function createMonster()
local template = ServerStorage:FindFirstChild([Link])
if not template then return end
local monster = template:Clone()
[Link] = [Link]
[Link] = workspace
monster:SetPrimaryPartCFrame([Link]([Link](-100, 100), 10,
[Link](-100, 100)))
local humanoid = monster:FindFirstChildOfClass("Humanoid")
if humanoid then [Link] = [Link] end
return monster
end
local function attackPlayer(monster, player)
if not [Link] then return end
local humanoid = [Link]:FindFirstChildOfClass("Humanoid")
if humanoid and [Link] > 0 then
humanoid:TakeDamage([Link])
NotifyEvent:FireClient(player, "O " .. [Link] .. " te
atacou!")
end
end
local function chaseLoop(monster)
[Link](function()
local humanoid = monster:FindFirstChildOfClass("Humanoid")
local root = monster:FindFirstChild("HumanoidRootPart")
if not humanoid or not root then return end
while [Link] > 0 do
local target, dist = getNearestPlayer([Link])
if target and [Link] and dist < [Link] then
local tRoot =
[Link]:FindFirstChild("HumanoidRootPart")
if tRoot then
[Link] = [Link]
local path = PathfindingService:CreatePath()
path:ComputeAsync([Link], [Link])
for _, wp in ipairs(path:GetWaypoints()) do
if [Link] <= 0 then break end
humanoid:MoveTo([Link])
[Link]:Wait()
if ([Link] - [Link]).Magnitude
<= [Link] then
attackPlayer(monster, target)
end
end
end
else
[Link] = [Link]
[Link](1)
end
[Link](0.2)
end
monster:Destroy()
end)
end
[Link](function()
while true do
local count = 0
for _, obj in ipairs(workspace:GetChildren()) do
if [Link] == [Link] then
count += 1
end
end
if count < [Link] then
local newMonster = createMonster()
if newMonster then chaseLoop(newMonster) end
end
[Link]([Link])
end
end)