Timer doesn't work

I feel Really stupid right now, anyways i’m making a donation board system and i want to make a timer to indicate when the board is going to update but the text doesnt change why? not sure.

local function Timer()
	local time = 2
	while wait(2) do
		if time == 0 then
			gui.main.Title.text = "Updating Donation Board"
	break
	 else
		warn(tostring(time))
	    time = time - 1
	end
  end
end

while true do 
Timer()
end
local function Timer()
	local Time = 2
	for i = Time, 0, -1 do
		task.wait(1)
	end
	
	gui.main.Title.text = "Updating Donation Board"
end

while true do 
	Timer()
end

You may want to change the text afterwards so that it isn’t stuck.

1 Like


The text Donations didnt change but the print statment worked

local function Timer()
	local Time = 2
	for i = Time, 0, -1 do
		task.wait(1)
	end
	gui.Main.Title.Text = "Updating Donation Board in "..tostring(Time)
	print("Updating")
end

print(gui.Main.Title.Text)

Add this somewhere. Might be a SurfaceGui related issue.


Pretty sure its just a Surfacegui problem i even tried doing it so like

local function Timer()
	local Time = 2
	for i = Time, 0, -1 do
		task.wait(1)
	end
	gui.Main.Title.Set.Value = "Updating Donation Board in "..tostring(Time)
	gui.Main.Title.Text = gui.Main.Title.Set.Value
end

and it didnt work either

Ah get the issue. You just need to put the line you’re changing the text inside the for loop. Here’s the full code now:

local function Timer()
	local Time = 2
	for i = Time, 0, -1 do
		task.wait(1)
        gui.Main.Title.Set.Value = "Updating Donation Board in "..tostring(i)
        gui.Main.Title.Text = gui.Main.Title.Set.Value
	end
end

The reason why you need to do this, is because the text and the value will change after the for loop is over.

Edit
  1. Fixed a little bit of issues with the script. It should be perfect now!
  2. Grammar correction. (Excuse me with my terrible grammar)

Thanks for this but it doesnt work :slight_smile: it has something to do with the surface gui

where exactly is the text suppose to go? I don’t see a spot where it would be anyway.

you should also check if the textlabel is visible or not, and texttransparency ~=1

you can also test print the gui.text because I do believe it is changing.

so at the screen shot where i replied to fourmer about that big donation text thats where the text is suppose to go and i dont think it has anything to do with transparency since the text is already visiable pretty sure its a surfacegui issue but thanks for the reply :+1:

something is not right on your end which is why I’m saying it is changing, but its invisible for whatever reason, its just speculation though cause idk what u mean by surface gui issue, if you are indeed setting the .text then it should change

local textlabel = script.Parent.TextLabel

for i=30, 0, -1 do
	textlabel.Text="timer = " .. i
	wait(1)
end

Code Used

local function Timer()
	local Time = 2
	for i = Time, 0, -1 do
		task.wait(1)
		gui.Main.Title.Set.Value = "Updating Donation Board in "..tostring(i)
		gui.Main.Title.Text = gui.Main.Title.Set.Value
	end
end
1 Like

that is very weird and I don’t think anyone can help just by looking at code (the code is functional too) because there is a different underlying issue

Is it possible to post the donation board itself so I can download and check around myself?

Not sure, what’s the problem. But maybe try this, I guess?

local function Timer()
	local Time = 2
	for i = Time, 0, -1 do
		task.wait(1)
		gui.Main.Title.Set.Value = "Updating Donation Board in "..tostring(i)
	end
end

gui.Main.Title.Set:GetPropertyChangedSignal("Value"):Connect(function(changedValue)
    gui.Main.Title.Text = changedValue
end)