DevRenix
(renix)
June 25, 2022, 7:23pm
#1
This is what I have so far, it works. But I feel like there’s a simpler way to do it.
local NumPlayers = 0
game.Players.PlayerAdded:Connect(function(plr)
local Players = game.Players:GetPlayers()
NumPlayers = 0
for i = 1, #Players do
NumPlayers = NumPlayers + 1
end
print(NumPlayers)
end)
local Players = game:GetService("Players")
local Count = #Players:GetChildren()
DevRenix
(renix)
June 25, 2022, 7:25pm
#3
Thank you for the much simpler way. I don’t know why I made it so difficult, lol.
1 Like
By the way you could also just use
local Count = #Players:GetPlayers()
if you only want to get the Players and because GetPlayers
is meant for this
1 Like
Either will return the children of the Players
service.
1 Like
2112Jay
(2112Jay)
June 25, 2022, 7:29pm
#6
Didn’t we just vote on that … the clear winner!
1 Like
Forummer
(Forummer)
June 25, 2022, 7:50pm
#7
Yes but GetChildren()
will return an array of children of any class whereas GetPlayers()
will return an array of player objects exclusively.
4 Likes
2112Jay
(2112Jay)
June 25, 2022, 7:55pm
#8
Hmmm … clearly not the winner then
That’s what shortcuts get you. Hidden Errors!