Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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.

2 comments

0

If FE is enabled, then what would work?

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.

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

This discussion is preserved as it was. New answers, comments, and votes are closed.