Text not showing IntValue's value?

Hello, again.

I have made a script about a timer, and there is a problem where The gui’s text is not showing the intvalue’s value while its decreasing.

Here is a video showing the issue:
robloxapp-20220728-1045144.wmv (372.6 KB)

May I have some help? it would be appreciated, I really dont understand why this isnt working.

Here is the script for the timer.

local Time_Value = game.Workspace:WaitForChild('Time')
local TimeText = script.Parent

TimeText.Text = Time_Value.Value

repeat
	wait(1)
	Time_Value.Value -= 1
until
Time_Value.Value == 0

Time_Value.Changed:Connect(function(val)
	if val then
		TimeText.Text = Time_Value.Value
	end
end)

That’s because the repeat loop is yielding the entire thread and the connection does not occur until the loop is finished. Encase the loop in a coroutine or use task.spawn

Or reorganize your code such that the .Changed connection happens before the loop starts

1 Like

Wouldn’t it be better if you did this:

local Time_Value = game.Workspace:WaitForChild('Time')
local TimeText = script.Parent

TimeText.Text = Time_Value.Value

repeat
	Time_Value.Value -= 1
    TimeText.Text = Time_Value.Value
    wait(1)
until Time_Value.Value == 0
1 Like

My fault for dragging you both here. Thank you for helping me on this very simple code, I appreciate you guys.

1 Like

I will try this later on in my game. Thank you for sharing.

No problem, I hope this helped you!