So I've added a text label in the StarterGui and what it basically is supposed to do is just keep track of how many players are currently online.
At default, I kept the text in the label at "Players: 0/12".
When I try and update the text the properties of the label shows it is updated, but visually it isn't updated.
Also I don't add in the wait in the beginning, the value of the total players would just be 0...
Also if this means anything, I'm in ROBLOX studio, but I have tried it on play mode on the level.
wait(0.1) local players = game.Players:GetPlayers() local screenGUI = game.StarterGui.ScreenGui local screenGuiTLabel = game.StarterGui.ScreenGui.TextLabel local playercount = "Players: " .. #players .. "/12" function updatePlayerlist() screenGuiTLabel.Text = playercount end game:GetService("Players").PlayerAdded:connect(updatePlayerlist)
Thank you!
In your script, you are modifying descendants of the StarterGui
service, not the real copies of the descendants which belong to each Player
and which will be rendered on screen.
StarterGui
has a special function, which is to copy its contents into each Player
's personal PlayerGui
when they join the game or when they spawn. If you modify the contents of StarterGui
, you will change what each player sees when they join the game or when they respawn, but you won't change what each player sees at that moment.
You should keep track of the players and update the text in a LocalScript
, making sure to manipulate the copies under game.Players.SomePlayer.PlayerGui
rather than their template counterparts in StarterGui
.