Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 8 years ago
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

Log in to vote
2
Answered by
Netflixy 126
8 years ago
Edited 8 years ago

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.

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. Rodmane234 85 — 8y
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. Rodmane234 85 — 8y
Ad

Answer this question