RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"If player is with 200 studs do not remove zombies"
-- server script local zombie = game.ServerStorage.Zombie -- Assuming you have a model named 'Zombie' in ServerStorage local maxZombies = 50 -- Maximum number of zombies local spawnRate = 300 -- 5 minutes while true do local spawnZone = game.Workspace.SpawnZone -- Assuming you have a part named 'SpawnZone' in Workspace -- Check if any player is within 200 studs of the spawn zone local players = game:GetService("Players"):GetPlayers() local canSpawn = true for _, player in pairs(players) do if (player.Character.HumanoidRootPart.Position - spawnZone.Position).Magnitude < 200 then canSpawn = false break end end -- Spawn new zombies if canSpawn then for i = 1, maxZombies do local randomX = math.random(-spawnZone.Size.X/2, spawnZone.Size.X/2) local randomZ = math.random(-spawnZone.Size.Z/2, spawnZone.Size.Z/2) local spawnPoint = spawnZone.Position + Vector3.new(randomX, 0, randomZ) local newZombie = zombie:Clone() newZombie.Parent = game.Workspace newZombie.HumanoidRootPart.Position = spawnPoint end end task.wait(spawnRate) -- Adjust the spawn rate here end