Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I stop the function of a true condition while the false is running?

Hey. I know I didn't explain my question so well, it is pretty complicated/hard to explain, but I'll try my best. Basically, I'm making a countdown that whenever the amount of players in a team named "Room 5" is 1+ the timer will start counting down. The players get a button that lets them also leave their room, and it changes their team back to the default. Basically, this is how I did it, I will now explain the problem:

while wait() do
	if #game.Teams["Room 4"]:GetPlayers() >= 1 then
		for i = 25, 1, -1 do
			script.Parent.Text = "TIME LEFT: "..i 
			wait(1)
		end
		
	else
		
		script.Parent.Text = "NOT ENOUGH PLAYERS."
	end
end

Whenever the condition is becoming false, basically, whenever a player leaves the room, the false condition will run, but the true condition as well. Since it changes it's text each 1 secound, whenever I leave it it will almost instantly switch the text to the countdown suddenly. I want to know what to do that I will stop the true condition from running while the false is. Thanks!

1 answer

Hi!

It looks like you didn't add a break point to to your countdown.

local CountdownEnabled;

while true do

    if #game.Teams["Room 4"]:GetPLayers() > 1 then
        CountdownEnabled = true
        for i = 25, 1, -1 do
            if not CountdownEnabled then
                break
            end
            script.Parent.Text = "TIME LEFT: "..i
            wait(1)
        end
    else
        CountdownEnabled = false
    end

    wait()
end

Let me know if it doesn't work since I didn't test it!

3 comments

0

I will test it. Thanks!

0

Thank you. But it didn't work. Thanks anyways!

0

Are there any errors?

This discussion is preserved as it was. New answers, comments, and votes are closed.