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