local gameInProgress = false
local plrs = {}
local collectionservice = game:GetService("CollectionService")
local alive = "alive"
local gameOverSound = workspace:WaitForChild("gameOverSound")
game.Players.PlayerAdded:connect(function(plr)
table.insert(plrs,plr.Name)
for i,v in pairs(plrs) do
print(v)
end
end)
while true do
local ServerScripts = game:GetService('ServerScriptService')
local Activespawn = workspace.Wave:WaitForChild("spawnActive")
local msg = game.ReplicatedStorage:WaitForChild("RoundMessage")
local maps = game.ReplicatedStorage.Maps
wait(2)
for i = 25,0,-1 do
if gameInProgress == false then
msg.Value = "Intermission:"..i
wait (1)
if i ==0 then
gameInProgress = true
local chosenMap = math.random(1,3)
if chosenMap == 1 then
local map = maps.Normal:Clone()
map.Parent = workspace.Map
end
if chosenMap == 2 then
local map = maps.Green:Clone()
map.Parent = workspace.Map
end
if chosenMap == 3 then
local map = maps.Red:Clone()
map.Parent = workspace.Map
end
msg.Value = "Loading..."
wait(10)
msg.Value = "Game in Progress"
workspace.Wave.spawnActive.Value = true
target = CFrame.new(17.117, 15.322, 100.895) --could be near a brick or in a new area
for i, player in ipairs(game.Players:GetChildren()) do
--Make sure the character exists and its HumanoidRootPart exists
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
--add an offset of 5 for each character
player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
if player.Character.Humanoid.Health > 0 then
collectionservice:AddTag(player.Character, alive)
print("player tagged")
for i = 120,0,-1 do
if gameInProgress == true then
msg.Value = "Time Left: "..i
wait(1)
workspace.Wave.RunnerSpawns.Value = workspace.Wave.RunnerSpawns.Value + 0.05
local x = collectionservice:GetTagged(alive)
if #x == 0 then
print("Game over")
game.ReplicatedStorage.RoundMessage.Value = "Game Over!"
wait(6)
workspace.Map:ClearAllChildren()
wait(0.2)
workspace.Wave:WaitForChild("spawnActive").Value = false
workspace.Wave.RunnerSpawns.Value = 1
workspace.Wave.zombiesAlive.Value = 0
gameInProgress = false
player.PlayerGui.GameOver.Enabled = true
gameOverSound:Play()
wait(9)
player.PlayerGui.GameOver.Enabled = false
i = 0
end
player.Character.Humanoid.Died:Connect(function()
collectionservice:RemoveTag(player.Character, alive)
end)
end
if i == 0 then
local w = collectionservice:GetTagged(alive)
if #w > 0 then
print("winner!")
else
print("you lost!")
end
end
end
end
end
end
end
end
end
end |