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

I made a timer that is not working, what shall I do?

Before you read, this script is inserted into a Local Script which is inserted into a Text Label. I have made a counter of 6 seconds but it is not working, any ideas on why it is not working?

local text = "Game found! You will be teleported in 6"
wait(1)
local text = "Game found! You will be teleported in 5"
wait(1)
local text = "Game found! You will be teleported in 4"
wait(1)
local text = "Game found! You will be teleported in 3"
wait(1)
local text = "Game found! You will be teleported in 2"
wait(1)
local text = "Game found! You will be teleported in 1"
wait(1)
local text = "Get ready!" 

4 comments

0

Do Local text = script.Parent

0

you don't set the var "text" as the text of the label...

0

if this script is a child of the label you want to edit, use "script.Parent.Text = text"

0

thanks

2 answers

✓ Accepted answer

Because you never set the Text of the textLabel.

local textLabel = script.Parent
textLabel.Text = "Words"

Now, instead of typing out that message ten times with different numbers, you could use a for loop.

for q=6, 1, -1 do
	textLabel.Text = "Game found! You will be teleported in " .. q
	wait(1)
end

Here, we set up a for loop to start at 6, end at 1, and add -1 to the q variable each time the loop runs, we also concatenate our q variable to the end of the string.

And as a side note, the following code will not work.

local text = textLabel.Text
text = "Words"

In this situation, you set the text variable to whatever the text is in the textLabel, you cannot set the Text property like this.

Type Local text = script.Parent at the top of the code and then remove all the "local " from the code you have right now. Your Problem is that every time it is trying to save the value "text" as something new.

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