Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
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 943 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years 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 — 4y
0
Yeah that’s what I meant lol iamtryingtofindname 22 — 4y
Ad

Answer this question