Hello, I have created a script that has a NumberValue in a Folder inside of Workspace. Whenever somebody joins, it adds + 1 to the NumberValue. Whenever someone leaves, it does - 1. I am just curious to know if the way I am doing this is efficient because I know there is other ways of doing this. I also forgot to mention that whenever someone joins it just prints out 0 for some reason. Thanks!
Code:
numbers = game.Workspace.Numbers
value = numbers.PlayerCount.Value
game:GetService("Players").PlayerAdded:Connect(function()
numbers.PlayerCount.Value = numbers.PlayerCount.Value + 1
wait(1)
print(value)
end)
game:GetService("Players").PlayerRemoving:Connect(function()
numbers.PlayerCount.Value = numbers.PlayerCount.Value - 1
wait(1)
print(value)
end)
Thank You!

2 comments
Please don't post questions that have been asked before. The answer you're looking for can be found here: https://scriptinghelpers.org/questions/85605/how-to-see-how-many-players-there-are-in-your-server
I was only curious to know if the method i was using was as good as GetPlayers, it dont think its the same thing