game.Players.PlayerAdded:Connect(function() game.Workspace.Value.Value = game.Workspace.Value.Value + 1 end)
This script is supposed to add 1 to in value if a person join but it doesnt work. Any help will be appreciated!
Well first of all, if you are trying to get the amount of players in a game, just do
This will return an array of every player in the game when that is called, so if you want how many people, just add # in front like this
#game.Players:GetChildren() — This will return a number
As for your code, there isn’t much i can do, since it appears to be correct to me, so just check to make sure that that script is in ServerScriptService, and check for spelling, and make sure it actually exists, also you did not tell us what was not working about it, were there any errors?
But I would not reccomend using that to count players, use the method I showed you. Your method is bad practice and may not function as intended.
Also the PlayerAdded event has a parameter, which is the player that joined. Here is an example:
game.Players.PlayerAdded:Connect(function(Player) print(Player.Name) end)
That will print the players name whenever they join.
I hope this helps.