I'm making an intermission for my round-based game. So, like any intermission, I have a timer GUI. It's supposed to tick down for 15 seconds and when it gets to 0, it will teleport all players to the map.
The problem is, the TextLabel which I set the text to display the intermission timer's value will automatically stop ticking at 14. Can someone help? Here's my code:
01 | repstorage = game.ReplicatedStorage |
02 | timer = game.StarterGui.RoundTimer.TimerText |
03 |
04 | local intermission = Instance.new( "IntValue" ) |
05 | intermission.Name = "Intermission" |
06 | intermission.Value = 15 |
07 | intermission.Parent = game.ReplicatedStorage |
08 |
09 | function countdown() |
10 | repeat |
11 | intermission.Value = intermission.Value - 1 |
12 | timer.Text = intermission.Value |
13 | wait( 1 ) |
14 | until intermission.Value = = 0 |
15 |
go easy on me
You have to access the player's playerGui, not the starterGui!
Try this:
01 | repstorage = game.ReplicatedStorage |
02 |
03 | local intermission = Instance.new( "IntValue" ) |
04 | intermission.Name = "Intermission" |
05 | intermission.Value = 15 |
06 | intermission.Parent = game.ReplicatedStorage |
07 | function updateGui() |
08 | for x,y in pairs (players) do -- goes thru all the players (x = key, y = the player) |
09 | y.PlayerGui.RoundTimer.TimerText.Text = intermisson.Value -- Updates the gui |
10 | end |
11 | end |
12 | function countdown() |
13 | players = game.Players:GetChildren() -- I added this table of all the players |
14 | repeat |
15 | intermission.Value = intermission.Value - 1 |
Plz accept! (If it helped)
Maybe try this, I have an intermission script and it works fine.
01 | local timer = game.StarterGui.RoundTimer.TimerText |
02 |
03 | function intermission() |
04 | for i = 15 , 0 ,- 1 do |
05 | timer.Text = "" ..i.. "" |
06 | wait( 1 ) |
07 | end ) |
08 | while true do |
09 | intermission() |
10 | wait( 1 ) |
11 | end |
This should work. But it doesn't do it every time a player joins. Good Luck!