Player = game.Players:GetPlayerFromCharacter() countPlayers = game.Players.NumPlayers waitGui = game.Workspace.mainGui.lobbyWait waitText = waitGui.TextLabel.Text while countPlayers <= 1 do waitText = "testing, testing, 123" end
The GUI's text does not change.
Please help me resolve this.
Thank you.
The problem is that 'countPlayers' will always be the same because you're not defining it inside the loop. So if, initially, 'countPlayers' wasn't less than or equal to one then it will never change.
Also, you cannot change a property from a variable directly. If you set a variable to a property, the variable becomes 'read only'. Set 'waitText' to the TextLabel, not the Text property of it.
And I have no idea what you were doing with the GetPlayerFromCharacter method.
local num = 1 waitText = workspace.mainGui.lobbyWait.TextLabel while wait() do local countPlayers = game.Players.NumPlayers if countPlayers <= num then waitText.Text = "testing, testing, 123" end end
3 Things Unintentionally Done With Your Script:
Careful with while loops. You will need a "wait()," else Roblox will crash.
countPlayers
refer to the value of the NumPlayers property, not the property itself.
countPlayers
will always be the number that it is assigned to, so if the server starts, the initial amount of players in the game is 0.while game.Players.NumPlayers <= 1 do -- Code here wait() end
waitText
.while game.Players.NumPlayers <= 1 do waitGui.Textlabel.Text = "testing, testing, 123" wait() end
What's the purpose of the first line? Delete that line out if you're not going to use it. This is for efficiency.