RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"functional zombie"
-- server script (ServerScriptService) local zombie = game.Workspace.Zombie local pfs = game:GetService("PathfindingService") while true do local players = game:GetService("Players"):GetPlayers() local closestPlayer = nil local closestDistance = math.huge for _, player in ipairs(players) do local distance = (zombie.HumanoidRootPart.Position - player.Character.HumanoidRootPart.Position).Magnitude if distance < closestDistance then closestPlayer = player closestDistance = distance end end if closestPlayer then local path = pfs:CreatePath() path:ComputeAsync(zombie.HumanoidRootPart.Position, closestPlayer.Character.HumanoidRootPart.Position) for _, waypoint in pairs(path:GetWaypoints()) do zombie.Humanoid:MoveTo(waypoint.Position) zombie.Humanoid.MoveToFinished:Wait() end end wait(1) end