Ban whole group (members)

  1. What do you want to achieve? Keep it simple and clear!
    I found a lot of group that are only made to “host” their alt accounts on and to “invade” other groups like spamming the group wall, joining the game and spamming and bypassing chat filter and stuff like that. My idea now is, is it possible to ban all members of a specific group?

Does someone know a Roblox Ressource I can use for that? I know it’s possible to get the ranks of a specific group with the GroupID but does this apply to the specific members of a group?

Thank y’all already for you help. I’m not looking for a finished script or someone to script it for me. I just want input on it and ideas on how to make this work.

3 Likes

Player:GetRankInGroup() returns 0 if the player is not a mamber, and any other number means they are a member.

More info: Player | Documentation - Roblox Creator Hub

3 Likes

If there is multiple groups that you need to ban I would consider looking into this script. Didn’t test it yet so may have errors.

local bannedGroups = {}

local GroupService = game:GetService("GroupService")

game:GetService("Players").PlayerAdded:Connect(function(player)
    local playerIsInGroups = GroupService:GetGroupsAsync(player.UserId)
    for _,currentGroup in pairs(playerIsInGroups) do
        for i,currentBannedGroup in pairs(bannedGroups) do
            if currentGroup.Id == currentBannedGroup then
                player:Kick("Please leave the group "..currentGroup.Name.." to join this game.")
            end
         end
     end
end)
6 Likes

Player.IsInGroup function works too.

2 Likes

Oh well, thanks for that! I will look into that.

1 Like

Here is a link to the API reference to the GroupService:GetGroupsAsync. You can get a lot of information if you need more specific information like their rank or if they have it set as their primary group. Just rmeber this returns everything in a table.

2 Likes

Personally for my group, I developed a module script so that it can be updated out of the game but also update in-game without me needing to shut down my servers. If you’re interested, I’d be happy to share the code.

2 Likes

Here is a new version of my previous script that uses table.find() to better optimize the script! :smiley:

local bannedGroups = {} --Ids of groups that are banned from this game

local ignoreList = {} --Put UserIds that have an exception to the group ban

local GroupService = game:GetService("GroupService")

game:GetService("Players").PlayerAdded:Connect(function(player)
	local playerIsInGroups = GroupService:GetGroupsAsync(player.UserId)
	for _,currentGroup in pairs(playerIsInGroups) do
		if table.find(bannedGroups,currentGroup.Id) ~= nil and table.find(ignoreList,player.UserId) == nil then
			player:Kick("Please leave the group "..currentGroup.Name.." to play this game!")
		end
	end
end)
6 Likes