local PathfindingService = game:GetService("PathfindingService")
local Debris = game:GetService("Debris")
local Players = game:GetService("Players")
local Demon = script.Parent.DemonType
local destination = nil
local path = nil
local function updatePath()
if destination and destination.Character and destination.Character:FindFirstChild("HumanoidRootPart") then
local humanoidRootPart = destination.Character.HumanoidRootPart
local distance = (Demon.RootPart.Position - humanoidRootPart.Position).magnitude
if distance < 50 then
path = PathfindingService:CreatePath({
AgentRadius = 2;
AgentHeight = 5;
AgentCanJump = false;
})
path:ComputeAsync(Demon.RootPart.Position, humanoidRootPart.Position)
if path.Status == Enum.PathStatus.Success then
return path:GetWaypoints()
end
end
end
return nil
end
local function followPath(waypoints)
for _, waypoint in ipairs(waypoints) do
Demon:MoveTo(waypoint.Position)
Demon.MoveToFinished:Wait()
end
end
while true do
destinati
if destination then
local waypoints = updatePath()
if waypoints then
followPath(waypoints)
else
Demon:MoveTo(game.Workspace.Spawners.Spawner.SpawnPoint.Position + Vector3.new(math.random(10), 0, math.random(10)))
Demon.MoveToFinished:Wait()
end
else
Demon:MoveTo(game.Workspace.Spawners.Spawner.SpawnPoint.Position)
end
wait(0.0001)
end
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}