Group Blackliist

Hey! I was wondering if anyone knew how to make a group blacklist system like this

“You are in a blacklisted group [Group: (name here)]”

but I will have more then 1 group ID there, so I was wondering if anyone knew how to make it display the group name they are in that is blacklisted

Thanks and sorry! I’m fairly new to scripting

3 Likes
local Players = game:GetService("Players") -- variable for player service

local blacklistedgroupids = { -- array of group ids, add any ids of your choice
	1,
	7,
}

-- playeradded event
Players.PlayerAdded:Connect(function(plr)
	for i,v in pairs(blacklistedgroupids) do -- loop through blacklisted group ids
		if plr:IsInGroup(v) then -- check if the plr is inside the group
			plr:Kick(string.format("You are in a blacklisted group [Group: (%s)]",  
-- string format for the name
game:GetService("GroupService"):GetGroupInfoAsync(v).Name) or "nil"
) -- %s would equal the group's name, then that will be the kick msg
		end
	end
end)

tldr: when the player joins, we will loop through the blacklisted group ids and check if the user is in the group id during a loop, if they are in the group then it will kick them and add the group name as requested

3 Likes

Awesome! Thanks I’ll give it a shot!

1 Like