Log in to vote
0

# Why does my GUI text not change to the intermission time?

Asked by 3 years ago

I tried to make a minigame intermission script but it isn't working, my script is down below.

 --// Variables
local MapStorage = workspace.MapStorage
local IntermissionTime = 15
local Players = game.Players:GetChildren()
local Status = game.ReplicatedStorage.StatusValue.Value
local RoundInProgress = false

--// Intermission
while wait(1) do
if not RoundInProgress and #Players > 2 then
for i = IntermissionTime, 0, -1 do
Status = "Intermission: ".. i
end
elseif not RoundInProgress and #Players < 2 then
Status = "2 or more players are required to start"
end
end


I also have a script in the gui which sets the text to the status value, that is working fine so I narrowed this script down to the problem.

### 1 answer

Log in to vote
0
Answered by
RayCurse 1513
3 years ago
Edited 3 years ago

First of all, your status variable needs to be the instance of the StringValue itself and not the value because you need to change the value later on. Second, you should add a wait() around line thirteen where the script is counting down the intermission. Third, your script needs a way to break out of the for loop just in case a player leaves while the game is counting down. Finally, the script should probably be able to break out of the while loop as well when the game starts. This would make the script look like this:

 --// Variables
local MapStorage = workspace.MapStorage
local IntermissionTime = 15
local Players = game.Players:GetChildren()
local Status = game.ReplicatedStorage.StatusValue
local RoundInProgress = false

--// Intermission
while wait(1) do
if not RoundInProgress and #Players > 2 then
local startRound = false
for i = IntermissionTime, 0, -1 do
if #Players < 2 then break end
Status.Value = "Intermission: ".. i
wait(1)
if i == 0 then startRound = true end
end
if startRound then break end
elseif not RoundInProgress and #Players < 2 then
Status.Value = "2 or more players are required to start"
end
end

0
It still doesn't work when the game has more than two people cmgtotalyawesome 1333 — 3y
0
Do you want to start the game when there are two or more players or when there are more than two players? RayCurse 1513 — 3y