0

# Int Value adding not working when a player is being added. HELP?

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!

0
Are there any errors in console? virushunter9 514 — 5mo

1
Edited 5 months ago

Well first of all, if you are trying to get the amount of players in a game, just do

game.Players:GetChildren()


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.

0
I would recommend :GetPlayers() function instead. yuni_Boy1234 320 — 5mo
0
Yeah that’s what I meant lol iamtryingtofindname 22 — 5mo