Because NumPlayers is not a value of players, and two, you dont need that long variable. plus, "StarterGui" is a place in bject unto which you put the gui. Its complicated. if you understand hiarchy and such, here is how it works: the objects in the startergui and starterpack containers clone into a new players "Backpack" and "PlayerGui". so the way you have it, it wont change anyway, but if it did, it would change the one in the place nobody sees until they spawn. What you need is the following script:
local label = game.StarterGui.NumPlayerGui.TextLabel
while true do
label.Text = "Players In Server: ".. game.Players.NumPlayers
wait(1)
end
heres the one you are looking for, and you put this in the label in the screeengui, in the startergui
and actually, it should be whenever a new player enters, so we make it a function, not a loop.
local label = script.Parent
local NumPlayers = 0
game.Players.PlayerAdded:connect(function()
for i, v do in pairs(game.Players:GetChildren()) do
NumPlayers = Numplayers+1
end
label.Text = "Players In Server: " ..NumPlayers
NumPlayers = 0
end)
The reason why it was made a function was because it will work the best, the for loop because it gives an accurate number, and we changed it back to 0 to reset. its all on the iki for a basic outline, as long as you can put two and two together.
6 comments
I just looked a t the script, i didnt realize Players.NumPlayers was a actual value. But this script works just as well and to be honest, is probably more efficient, to reduce lag, and you can take out the for loop, and replace the variable of "NumPlayers = 0" to "NumPlayers = game.Players.NumPlayers"
 PlayerAdded events don't work well in local scripts for they only fire for their specific client!
But it still works non the less, and they will fire at the same time, and it doesnt have to be a local script.
Aye, it may work as a server script, but it would be most efficient as a LocalScript considering that it's inside the Player.
Yes, and here is the thing, PlayerAdded:connect() will fire at the same time, this will prevent much lag throughout the client, instead of a loop.
My point is that PlayerAdded events don't work as expected in LocalScripts; http://wiki.roblox.com/index.php?title=PlayerAdded