for i, v in pairs(game.Players:GetChildren()) do if v.Name ~= game.Players.LocalPlayer.Name then v:Kick() end end
So basically when this script runs, it kicks everyone in the game but I keep getting an error saying expected '=' near 'is'
.
Do you guys know how to fix this??
There is no is
in the code snippet that you posted. I am guessing that the error occured elsewhere outside of this snippet.
If FilteringEnabled is turned on then this script won't work. A client should not be able to kick other players.
name = "kools" for i, v in pairs(game.Players:GetChildren()) do if v.Name ~= name then v:Kick() end end
That's how I would write the script from the server-side. This hardly answers your question however.
local name = { -- Put in the players that are allowed in this array-- } -- Since you are not using the counter(i) in the loop, I simply put in an _ for _, v in pairs(game.Players:GetPlayers()) do -- Get the players instead, what if you have a script inside, you are not able to kick a script right, that's why we have the GetPlayers function if (v.Name ~= name[1] or v.Name ~= name[2]) then v:Kick() elseif (v.Name == name[1] or v.Name == name[2]) then return -- Just keeps going and returns nothing end end