Hello! Basically, I was testing a lobby system, When I came across an error, Basically, It runs the “EndRound” Function every single second, Instead of just ending the script and restarting a new match.
Here is a visual:
And here is a snippet of the code:
local function EndRound(clonedMap)
for _, player in ipairs(playerTable) do
if player.Character then
MapUnloadEvent:FireClient(player)
player:LoadCharacter()
RoundEndingEvent:Invoke()
end
end
clonedMap:Destroy()
print("Sucessfully Ended Round!")
end
local function CheckAmountOfPlayers(ClonedMap)
task.wait(1)
if #workspace.Ingame:GetChildren() <= 1 then
EndRound(ClonedMap)
print("End")
end
end
local valuesFolder = clonedMap:WaitForChild("Data")
if valuesFolder then
local timeValue = valuesFolder:FindFirstChild("Time")
if timeValue then
for i = timeValue.Value, 1, -1 do
StatusValue.Value = "GAME TIME: " .. i
CheckAmountOfPlayers(clonedMap)
task.wait(1)
end
end
end
EndRound(clonedMap)
Help appreciated