Ok. So I want to select all players that aren't me. I will use this to make them stop moving, and I was thinking about making a table. Like
local plrs = ... local MasterControl = require(plrs:WaitForChild("PlayerScripts"):WaitForChild("ControlScript"):WaitForChild("MasterControl")) MasterControl:Disable() MasterControl:Enable()
So. 1st Question) Would this work? 2nd Question) How to I select ALL other players in-game?
Thank you for your help.
To select all players in a game, you can use a for loop.
for i, loopPlayer in pairs(game.Players:GetPlayers()) do --Disable master control here using "loopPlayer" as player-- end
Basically, the for loop will get a list of all the current players in the game with game.Players:GetPlayers()
and then it will loop through each player found.
Every loop it will assign the variable loopPlayer
to the player it has looped through. Then it will do the code to the player, then it will move on to the next player in the game, and do the same code to that player.
For example, if I wanted to kill every player in the game, I could do this:
for i, loopPlayer in pairs(game.Players:GetPlayers()) do loopPlayer.Humanoid.Health = 0 end
This would loop through every player, then make that player's health 0.
Keep in mind, i
is the number amount of times the loop has run, and you can name that to anything. loopPlayer
is also just a variable and you can name that to anything.