Whenever it gets time to do roundtime, it already says the round is over. Help?
players = game.Players:GetPlayers()
h = Instance.new("Hint", workspace)
maps = game.ServerStorage:FindFirstChild("Maps"):GetChildren()
getsword = game.ServerStorage:FindFirstChild("Sword")
while wait(1) do
if game.Players.NumPlayers >= 2 then
h.Text = "Starting a new round!"
wait(3)
h.Text = "Choosing a random map..."
wait(3)
local chosenmap = maps[math.random(1, #maps)]:Clone()
chosenmap.Parent = workspace
h.Text = "The map is " .. chosenmap.Name .. " by " .. chosenmap.Creator.Value .. "!"
wait(3)
h.Text = "Teleporting players..."
wait(3)
for i, v in pairs(players) do
if v.Character.Humanoid.Health > 0 and v ~= nil then
local spawns = chosenmap:FindFirstChild("Spawns"):GetChildren()
local sword = getsword:Clone()
v.Character:MoveTo(spawns[i].Position)
sword.Parent = v.Backpack
end
end
local roundtime = 60
local dead = 0
while wait(1) and roundtime > 0 and dead < #players do
h.Text = "Time until next round " .. roundtime
roundtime = roundtime - 1
end
for i, v in pairs(players) do
v.Character.Died:connect(function()
dead = dead + 1
end)
end
h.Text = "The time is up!"
wait(3)
for i, v in pairs(players) do
if v.Character.Humanoid.Health > 0 and v ~= nil then
v:LoadCharacter()
end
end
else
h.Text = "Waiting for another player..."
end
end

1 comment
can you upvote and accept the answer please?