Timer won't work!

  1. What do you want to achieve?: I’m making a 30 second intermission timer for a game.

  2. What is the issue? The script is just supposed to countdown from 30 until it hits 0. When I put print (status.Value) in the output every second, it’ll print the numbers counting down. However, when you set the value of it to the text, the text will only change by 1. Instead of the timer stopping at 0, it’ll stop at -30.

  1. What solutions have you tried so far? I’ve tried looking up videos online and looking at other issues on the DevForum.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local seconds = game.ReplicatedStorage.Status
local clock = game.StarterGui.ScreenGUI.IntermissionFrame.IntermissionTimer.IntermissisonClock
clock.Text = seconds.Value

for i = 30, 0, -1 do
	repeat
		seconds.Value = seconds.Value - 1
		wait(1)
		clock.Text = seconds.Value
		print(seconds.Value)
	until
	seconds.Value <= 0
end
1 Like

This is the issue, you have a for loop that will repeat 30 times, but in your code you are doing another loop that will repeat.
so whats happening is that the for loops goes for the first time, then repeats the code until the value is <= 0 and the repeats the code 29 times more.
The solution is to remove the repeat until from the loop and thats is

1 Like

Ty, that fixes the issue with going to -30.
Can you help with it not setting to text?

1 Like

i think that could be because you are getting the gui from the startergui instead of the playergui

1 Like

Where is your script located? You will need to use a LocalScript to do this inside of a Gui.

Hey, try the put the script as a child of the clock and use script.Parent to reference it. Also, use tostring() for the text like this : clock.Text = tostring(seconds.Value)