while lime > 1 do
lime = 60
lime = lime -1
game.StarterGui.main.counter.Text = lime
end
This script for a countdown from 60 seconds is not working?
1 answer
Your script has a few issues:
- For one, you set
limeto be 60 on each iteration, effectively creating an infinite loop. - You don't have any sort of delay, so even if it wasn't an infinite loop it wouldn't be very effective.
- You make changes to
StarterGui, rather thanPlayerGui.
When creating a countdown, you generally want to use a numeric for. I'll let the wiki explain what that is. You can easily change your script to use a numeric for:
for lime = 60, 1, -1 do
game.StarterGui.main.counter.Text = lime
end
That handles the first problem, but there are still two problems with this. The first one is a really common mistake. You used StarterGui to try to change the contents of players' GUIs. Check out the blog post[^1] for an explanation of that.
The second issue is that there's no delay-- the loop will almost instantly finish because you don't wait. This can be easily remedied:
for lime = 60, 1, -1 do
game.StarterGui.main.counter.Text = lime
wait(1)
end
This doesn't fix the StarterGui issue, though. Depending on whether you have Filtering enabled or not, you can go about fixing this differently. Personally, I'd prefer using a RemoteEvent either way. The blog post[^1] shows you a different way to go about it, if you prefer that method. I'm going to let you decide how to go about doing that.
Hope this helped.
P.S.: In the future, please explain your problem in full (i.e., explain exactly what happens) using your post, not only the title.
[^1]: Common Mistakes
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Reading the script killed me. But for real, I can't understand this script.
You can't change the StarterGUI, the player's starter GUI is in a folder called PlayerGUI.