I have a number value inside a TextLabel, and the TextLabel is supposed to tell the player how many people are on the server. i wasn't sure how to go about this so I tried this:
The script inside the Value:
plr = game.Players:GetPlayers() game.Players.PlayerAdded:connect(function() script.Parent.Value = plr return #plr end) game.Players.PlayerRemoving:connect(function() script.Parent.Value = plr return #plr end)
The Value is 0 in the PlayerGui
the script inside the TextLabel:
script.Parent.Text = "Players Online\n".. script.Parent:WaitForChild("Value").Value script.Parent:WaitForChild("Value").Changed:connect(function() script.Parent.Text = "Players Online\n".. script.Parent.Value.Value end)
There is nothing in output, and nothing in that F9 thing. The TextLabel says
Players Online 0
There are two ways to find the number of players in a server.
The first:
--localscript inside StarterGui local players=script.Parent.Parent.Parent:GetChildren() --make sure you have enough .Parent's to get a table of everything inside of Players --script.Parent.Parent... ... until the script is looking at PlayerGui then add .Parent.Parent to that. --Stuff>PlayerGui>Player>Players --#players is the number of players in the server
The second:
game.Players.NumPlayers --read-only property telling how many players per server
You don't need a value at all, and you also only need only 1 script
script.Parent.Text = "Players Online\n".. script.Parent.Parent.Parent.Parent.NumPlayers --you might have to adjust the amount of .Parent's
If you want it to change each time a player joins or leaves:
function Update() script.Parent.Text = "Players Online\n".. script.Parent.Parent.Parent.Parent.NumPlayers --you might have to adjust the amount of .Parent's end script.Parent.Parent.Parent.Parent.ChildAdded:connect(Update) script.Parent.Parent.Parent.Parent.ChildRemoved:connect(Update)