RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"zombie survival"
-- server script for spawning zombies local zombieSpawn = game.Workspace.ZombieSpawn while true do local zombie = game.ServerStorage.Zombie:Clone() zombie.Parent = game.Workspace zombie.Position = zombieSpawn.Position task.wait(10) end -- server script for zombie AI local zombies = game.Workspace:GetChildren() for _, zombie in pairs(zombies) do if zombie:IsA("Model") and zombie.Name == "Zombie" then local humanoid = zombie:FindFirstChild("Humanoid") if humanoid then local target = nil while true do local closestDistance = math.huge for _, player in pairs(game.Players:GetPlayers()) do local distance = (player.Character.HumanoidRootPart.Position - zombie.HumanoidRootPart.Position).magnitude if distance < closestDistance then closestDistance = distance target = player.Character end end if target then humanoid:MoveTo(target.HumanoidRootPart.Position) end task.wait(2) end end end end