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

Why is my countdown script not working in the manner that I desire?

local count = 60
local gui = script.Parent.Parent.Numbers
local text = gui.Text
for i=0,60 do
	text = count .. "sec"
	count = count - 1
	wait(1)	
end
text = "Charged!"

Sorry about the title, it's just scriptinghelpers being a beyoaotch. Anyway, script is above. Don't know what's wrong, there is no output log.

1 answer

First off all, your loop is running 61 times which i assume you do not want. And there is a "more effective" way to do this. Also, you change the text before you change the count.

local gui = script.Parent.Parent.Numbers
local text = gui.Text
for i=60,1,-1 do --Going from 60 to 1, decreasing by 1 each time
    text = i .. " sec"
    wait(1) 
end
text = "Charged!"

In this script you wont need the count value.

2 comments

0

This script does not work. I guess it's worth mentioning that I'm trying to change the text of a TextBox in a SurfaceGui. Does that mean anything? I guess it is.

0

I rewrote my script in a simpler way, and it worked, for some strange reason. I appreciate your help, but it wasn't necessary in the end.

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