How can I find and loop through every player currently in the game? I have enabled filtering so I need to change a lot of my scripts.
And should this script be in "ServerScriptService"?
How can I find and loop through every player currently in the game? I have enabled filtering so I need to change a lot of my scripts.
And should this script be in "ServerScriptService"?
This could be in SeverScriptService or Workspace. If by "looping through every player", you mean using the GetChildren method, then I recommend using a for loop. The other for loop is pairs. Exmaple:
for i,v in pairs(game.Players:GetChildren()) do
v:Kick()
end
Sorry for the spacing. I'm not in studio.
The above script would kick each player in the game.
You would use a for loop and the GetChildren() method.
for i,v in pairs(game.Players:GetChildren()) do --States the for loop, which gets all the children's names and prints them in v
print(v) --Prints the players names
wait() --So the for loop doesn't crash
end --Ends the for loop
VOTE +1 IF THIS HELPED :)
This discussion is preserved as it was. New answers, comments, and votes are closed.
5 comments
The reason whay i was asking if it would work in SeverScriptService is becouse this script is not sent to the client
Good question though. If you need more help on this subject, PM me on ROBLOX and I'll gladly help.
I prefer :GetPlayers since it won't effect other children in Players, if any were to be placed.
That would work as well. Normally, people don't play any other objects to become a descendant of Players. There's really no need to.
Use GetPlayers noob jk.