Kick multiple groups?

So I have this small little script that if you are in a group, it kicks you, but I want to make it so it checks multiple groups, and if you are in one of them, you get kicked, how would I do this?\

local Players = game:GetService("Players")

groupId = 0;

function onPlayerAdd(player)
	local rank = player:GetRankInGroup(groupId)
	if (player:IsInGroup(groupId)) then
		player:Kick("You have been kicked from the game")
	else
		player:Kick("You have been kicked from the game")
	end
end

Players.PlayerAdded:connect(onPlayerAdd);
1 Like

Try using or

If player:IsInGroup(groupId) or player:IsInGroup(groupId) then

1 Like

Try this function:

local groupIds = {}

function playerInGroup(plr)
    for _, groupId in pairs(groupIds) then
        if plr:IsInGroup(groupId) then
            return true
        end
    end
    return false
end
3 Likes

ÂżDo you want to make a kick system for more than 1 groups?

Try to use the group id and adjunt it

local Groups = And u make it

local Groups= {GroupId, GroupId , etc};

local function isInBanned(plr)
for i, v in pairs(banned_groups) do
if plr:IsInGroup(v) then
return true;
end
end
return;
end

game:GetService(‘Players’).PlayerAdded:connect(function(plr)
if isInBanned(plr) then
plr:Kick(“Kicked”);
end
end)

Enjoy

1 Like

Note that the kick screen already includes You have been kicked from the game. Anything you include in the Kick function is added onto that.

Additionally, you should avoid kicking people in specific groups as it can discourage gameplay experiences.

Im kicking mostly known exploiter groups.

1 Like

Instead, just put effort into good security. What’s the point of banning members in that group when they mostly all have alts?

Still, better safe than sorry, and with no way of avoiding game stealing, its one of my main focus’s.

What you need to understand is that you will get exploiters in your game (even when banning these groups) instead of blocking the issue from joining, stop the issue from causing a problem (write your code with security in mind)

2 Likes

If I wanted to disrupt your game experience, I am unlikely to be in a group as that can incriminate me.

Banning groups is a bad idea and will only cause bad player experience.

2 Likes

Alright. I will keep this in mind

2 Likes
local group_blacklist = {
    0;
    0;
    0;
}

game:GetService("Players").PlayerAdded:Connect(function(player)
    for _,id in ipairs(group_blacklist) do
        if player:IsInGroup(id) then
            player:Kick("You are part of a blacklisted group")
        end
    end
end)

Just to add onto @ElliottLMz’s reply, most exploiters don’t belong to a group on the roblox platform. They can easily bypass this system by creating a new account or leaving the group. If you want to bar individual exploiters from accessing your game, focus on having good game security with exploit detection.

Personally, I use a ‘strike’ system where the server will flag a player if it detects unusual activity from them, such as erratic changes in the y-component of their position in relation to the ground below them (flying), excessive firing of RemoteEvents or RemoteFunctions, or invalid/impossible arguments sent through these remotes. If a player is flagged enough times (to rule out false positives), they are kicked from the game.

Hope this helped! :smiley: