This is a part of my Duels Game script and the problem is whenever the timer reaches 0 or a player wins, I'm trying to respawn the player. The problem is, it's infinity respawning the player instead of breaking out the loop. If anyone knows the problem, that would be awesome.
for gametimer = 60, 0, -1 do
if gametimer == 0 then
status.Value = "Time up!"
for _, v in pairs(_G.duelers) do
if v then
v:LoadCharacter()
end
end
break
end
if #_G.duelers == 1 then
for _, v in pairs(_G.duelers) do
if v then
status.Value = v .. " is the winner!"
game.Players[v].leaderstats.Cash.Value = game.Players[v].leaderstats.Cash.Value + 50
v:LoadCharacter()
break
end
end
elseif #_G.duelers == 0 then
status.Value = "There was a tie!"
break
else
status.Value = gametimer .. " seconds until the round is over!"
end
wait(1)
end

1 comment
He used the 'break' in order to get out of the for loop..Also he should be checking for the winners within the loop in case they finish on time