How do I prevent higher roles from getting kicked?

I’m trying to make a script where if you are the member role in the group, you will be kicked from the game. But the issue I’m having is that if I set it to the member rank, higher ranks will be kicked as well and I don’t want that. Here’s the script:

game.Players.PlayerAdded:Connect(function(plr)
	if plr:GetRankInGroup(REDACTED) >= 1 then
		plr:Kick()
	end
end)

You could give a player a bool value if they have a certain role. If they have that bool they are kicked.

Right now you only have it set so that any ranks above the member role will be kicked. You need to make a second condition that limits the higher ranks. You can achieve this by doing this:

game.Players.PlayerAdded:Connect(function(plr)
	if plr:GetRankInGroup(REDACTED) >= 1 and plr:GetRankInGroup(REDACTED) <= 200 then
		plr:Kick()
	end
end)

200 is the rank in which you want the script NOT TO KICK beyond that. You can change that to your liking

Oh I didn’t notice he is using a greater than sign. I thought he would know to do that. I thought he was having a error with this.

I tried your script and changed the id for the role and it still kicks the higher role.

local HigherRank = 200 -- Change This to the Higher Rank Boundary
game.Players.PlayerAdded:Connect(function(plr)
	if plr:GetRankInGroup(REDACTED) <= HigherRank then
		plr:Kick()
	end
end)

Try it this way

Still kicks the role that I don’t want to kick.

What is the rank of the role you do not want kicked, and what is “REDACTED” defined as?

Oh wait, scratch that, I see why. I added an equals sign after the less than inequality, which makes it “less than or equal to.” That was my silly mistake. Try this instead.

local HigherRank = 200 -- Change This to the Higher Rank Boundary
game.Players.PlayerAdded:Connect(function(plr)
	if plr:GetRankInGroup(REDACTED) < HigherRank then
		plr:Kick()
	end
end)
1 Like

“REDACTED” is the group id for the roles.

It worked! Thanks for the help!

1 Like