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

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

Asked by 5 years ago
Edited 5 years ago

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!" 
0
Do Local text = script.Parent sunny_sunshine1221 -5 — 5y
0
you don't set the var "text" as the text of the label... Leamir 3138 — 5y
0
if this script is a child of the label you want to edit, use "script.Parent.Text = text" Leamir 3138 — 5y
0
thanks SwingingMelons -18 — 5y

2 answers

Log in to vote
0
Answered by
theCJarmy7 1293 Moderation Voter
5 years ago
Edited 5 years ago

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.

Ad
Log in to vote
0
Answered by 5 years ago

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.

Answer this question