I tried this script:
if script.Parent.Parent.Text1.Text == "2" then while true do repeat seconds = seconds - 1 script.Parent.Text = tostring(seconds) wait(1) until seconds == 0 script.Parent.Text = tostring("Teleporting Players...") wait(5) seconds = 26 end end
This code is put in a script that is in a text label that is in a surface gui, and in that surface gui are 3 more text labels. The one i want to specify is "Text1". When Text1 shows up "2" i want that countdown script happen.
Pls help!
Okay, I hope this can help you
First, try using the Changed
event, as using an if statement just checks once.
Then, this is not required, but why do you need to use tostring()
on a string in line 8? It is already a string
script.Parent.Parent.Text1.Changed:Connect(function(property) -- replace if with changed if property == "Text" and script.Parent.Parent.Text1.Text == "2" then -- if the text changed, and if the text is "2" then while true do repeat seconds = seconds - 1 script.Parent.Text = tostring(seconds) wait(1) until seconds == 0 script.Parent.Text = "Teleporting Players..." -- why the tostring() ? wait(5) seconds = 26 end end end
Hope this helps :)