Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I'm creating an auto-kick script but it won't work, any ideas?

Asked by 6 years ago
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??

2 answers

Log in to vote
0
Answered by 6 years ago

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.

0
If FE is enabled, then what would work? Thelegendofglitcher2 49 — 6y
0
I don't know what functionality you are looking for. If you want a player to kick everyone else then you will need to use RemoteEvents. User#18718 0 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
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

Answer this question