Loop repeating itself

Hi.
My loop is… not behaving correctly. Thats the only way to put it.

spawn(function()
	while wait(1) do
		if running1 == true then
			if seconds1 < 1 then
				seconds1 = 30
				running1 = false
				chosenOption = "None"
				break
			end

			seconds1 = seconds1 - 1
			Request.Countdown.Text = seconds1
		end
	end
end)

Request.Accept.MouseButton1Click:Connect(function(player)
	running1 = false
	Request.Visible = false
	chosenOption = true
end)

Request.Decline.MouseButton1Click:Connect(function()
	running1 = false
	Request.Visible = false
	chosenOption = false
end)

The first time it does it is perfectly fine. But then the second time, the countdown starts going down fast, as if there were two loops doing it. I don’t know man please help ill give you the rest of the code if I have to my brain hurts i’ve been trying to get this stupid stupid thing solved for an hour

1 Like

How is it running twice? You have a break in your while loop.

1 Like

Yes.

Thats… why I made the post.

1 Like
spawn(function()
	while wait(1) do
		if running1 == true then
			if seconds1 < 1 then
				seconds1 = 30
				running1 = false
				chosenOption = "None"
				break
			end

			seconds1 = seconds1 - 1
			Request.Countdown.Text = seconds1
		else
			break
		end
	end
end)

I think that’s the issue where the loop is not ending and the running1 value gets changed falsey before it reaches the if statement.

2 Likes

Wow. I-

I don’t even know what to say. I spent an agonizing hour trying to fix this and even considered giving up and moving onto something else, when all I had to do was that.

Thanks anyway.

1 Like