When a round is in progress and the timer is running and when a new player joins and spawns to the lobby my timer freezes. Is there a way to fix this?
My game script:
local GameTime = 120
while true do
wait(5)
local Hint = Instance.new("Hint", workspace)
Hint.Text = "Game starting!"
wait(1)
local RandomNumber = math.random(1,2)
local Map = game.ServerStorage["Map" .. RandomNumber]
Map:Clone().Parent = workspace.MapFolder
ftime = GameTime
local SpawnCount = Map.SpawnCount
for _, v in pairs(game.Players:GetChildren()) do
Player = Instance.new("StringValue", workspace.Players)
Player.Name = v.Name
randomN = math.random(1, SpawnCount.Value)
v.Character.HumanoidRootPart.CFrame = CFrame.new(Map:FindFirstChild("Spawn" .. randomN).Position+Vector3.new(0, 3, 0))
end
while true do
wait(1)
ftime = ftime -1
Hint.Text = "Game ending in: " .. ftime
Playing = workspace.Players:GetChildren()
if #Playing == 0 then
for _, v in pairs(workspace.MapFolder:GetChildren()) do
v:Destroy()
end
break
end
if ftime == 0 then
for _, v in pairs(workspace.MapFolder:GetChildren()) do
v:Destroy()
end
break
end
for _, v in pairs(game.Players:GetChildren()) do
if v.Character.Humanoid.Health == 0 then
workspace.Players[v.Name]:Destroy()
end
end
end
for _, v in pairs(workspace.Players:GetChildren()) do
workspace[v.Name].Humanoid.Health = 0
game.Players[v.Name].leaderstats.Cash.Value = game.Players[v.Name].leaderstats.Cash.Value +5
end
end
Thank You and Help is Appreciated

3 comments
What kind of script is this in?
it i a round intermission script and map choosing
Is it in a local script, or normal script?