local Main = game.StarterGui.ScreenGui.Main game.StarterGui.ScreenGui.Main.Text = "Finished loading! Welcome to "..game.Name wait(10) for countdown = 10,0,-1 do Main.Text = "Remaining time: "..countdown end
I'm not sure on how to properly use for loops for text labels. I'm trying to do a countdown timer but it's not changing the text at all, not even to "Remaining time: ".
The problem is you are modifying the StarterGui
which places all of its children into a new player's PlayerGui
. Modifying it would only change what a new player sees. Instead make sure its in a LocalScript
and put it anywhere really.
Also your code was kind-of all over the place, so I sorted it out alittle.
local Main = game.Players.LocalPlayer.PlayerGui.ScreenGui.Main Main.Text = "Finished loading! Welcome to " .. game.Name wait(10) for i = 10,0,-1 do Main.Text = "Remaining time: " .. countdown wait(1) end
LocalPlayer
is the client's player.
The reason why your text appears as 0 is because you forgot to add a wait. So here would be the new script:
local Main = game.StarterGui.Main game.StarterGui.ScreenGui.Main.Text = "Finished loading! Welcome to "..game.Name wait(10) for i = 10,0,-1 do Main.Text = "Remaining time: "..countdown wait(1) end
You see, if you do for
loops without waits or any delay, you'll see the stuff inside of the loop instantly appear, not like a smooth transition.
I hope I helped!