I want to make a script where if there are 2 or more players in the server, it will change the Gui's text at the top, and if there are less it will change it also, but whenever it gets to the line that changes the text, it returns nil. This is what I wrote:
NumOfPlayers = 2
gamewait = 10
while wait(2) do
local topGui = game.Players:GetChildren('Player')
wait(3)
if game.Players.NumPlayers > NumOfPlayers then
for i = 0, gamewait do -- 1
topGui.PlayerGui.ScreenGui.TextLabel.Text = "Next Game Starts In: " ..gamewait - i .." Seconds."
print('1')
wait(1)
end
else
if topGui then -- 2
topGui.PlayerGui.ScreenGui.TextLabel.Text = "There needs to be ".. NumOfPlayers - game.Players.NumPlayers .. " more player(s) to start the games."
print('2')
else
print('X-2')
end
end
end

3 comments
Are you using a local or server script?
What's with the "2" comment...
The comment is so I know where something went right or wrong.