Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

How to end for i loop which is inside while true do loop?

Asked by 5 years ago

I am working on minigames game and I need help with loops. So I have while true do and inside is for i loop then end of for loop and game script. But when timer says 0 timer will reset and start again from 10. I tried everything, please help. Sorry for mistakes in code below but in a studio is everything okay.

Code: local GameStatus = rep:FindFirstChild("Values"):FindFirstChild("GameStatus") game.Players.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function(Character) --Loop-- while true do local count = 10 for i = 1,10 do if count == 1 then GameStatus.Value = "The next map will be chosen in 1 second" else GameStatus.Value = "The next map will be chosen in "..count.." seconds!" end count = count -1 wait(1) if count == 0 then break end end

----Next is map choosing and teleporting players--

end--End of the loop-- end)--End of character added-- end)--End of player added

0
code blocks... lon233bcc 31 — 5y
0
Stop making loops and make it a loop inside a function your script is clumped and the server isnt understanding what your actually want i have had the same problem TheEpicNoob1111 15 — 5y
0
Also please put your script in lua format so i can help you with extra assistants TheEpicNoob1111 15 — 5y
0
Use the break keyword. DeceptiveCaster 3761 — 5y

1 answer

Log in to vote
1
Answered by
Nowaha 459 Moderation Voter
5 years ago

break

Ad

Answer this question