So i want to make a round system, like a deathmatch. The round is 10 minutes Long but if a player gets 30 kills then i want a bool value to be set to true. Therefore i want the round system to break once the bool value sets to true. How can i do this? Please help.
✓ ANSWER ACCEPTED
How would I break a loop based on a bool value changing?
3 answers
✓ Accepted answer
I would use a changed
kills.Value.Changed:Connect(function()
-- You can check how many kills they have and if they have a certain number it ends the
game
if kills.Value == 30 then
-- end the game
end
end)
I don't recommend using a while true do/ while wait() do or a repeat until since it checks a ton of times instead of just doing smthing when the value changes it makes the game lag a little.
if its a variable in a scrip do:
while wait(0.1) do
if Bool ~= true then
--Code
else
break --ends the loop
end
end
if its a value do:
Bool:GetPropertyChangeSignal("Value"):Connect(function()
if Bool.Value ~= true then
--Code
else
return
end
end)
2 comments
0
Well the main manager is a function, and inside the function is the loop. It is a bool value located in replicated storage. So do I connect the script inside the loop or what do i do?
0
I am kind of new to coding i am sorry
Thats exactly what repeat until loops are for.
repeat
-- round logic
until (statement)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
how would that break a loop though?