This while true do loop worked fine ~10 mins ago, but after altering some aspects of the code it no longer works. How come?
local Start = 0
local Time = 10
local RoundLabel = game.StarterGui.ScreenGui.RoundLabel
local Blackout = game.StarterGui.BlackoutGui.Frame
while true do
RoundLabel.Text = "The Round Starts in: "..Time.." Seconds!"
wait(1)
Time = Time - 1
if Time == Start then
break
end
end
RoundLabel.Text = "Starting the Round!"
wait(2)
Blackout.Visible = true
local Start = 0
local Time = 10
local RoundLabel = game.StarterGui.ScreenGui.RoundLabel
local Blackout = game.StarterGui.BlackoutGui.Frame
while task.wait() do
RoundLabel.Text = "The Round Starts in: "..Time.." Seconds!"
wait(1)
Time = Time - 1
if Time == Start then
break
end
end
RoundLabel.Text = "Starting the Round!"
wait(2)
Blackout.Visible = true
This won’t work, see @ZacharyZaxorDDD’s solution, your code has the same problem as OP. OP’s main code body works, it’s just that StarterGui is intended to store the initial state of the User Interface.
This looks like a mix of server and client code, but I’ll save that for another question.
PlayerGui is inherently separate from StarterGui. You are doing game.StarterGui, meaning you are altering the initial data state of the player gui, not the current state. You need to access the current ui state by indexing the player with .PlayerGui. This is why your solution will not work. Data from StarterGui does not feed into a player’s screen whatsoever.
local Start = 0
local Time = 10
local RoundLabel = script.Parent
local Blackout = script.Parent.Parent
while task.wait() do
RoundLabel.Text = "The Round Starts in: "..Time.." Seconds!"
wait(1)
Time = Time - 1
if Time == Start then
break
end
end
RoundLabel.Text = "Starting the Round!"
wait(2)
Blackout.Visible = true
Place inside the RoundLabel instance in StarterGui.
I’m aware, but I assume the original poster wanted this to influence the StarterGui not the PlayerGui. Considering his/her reference to StarterGui & not PlayerGui. All I did was change the way the loop was handled (as that is what was causing the issues before & when it was fixed the script worked) any other feedback you should give to the original poster & not me.