Hi, I am trying to makea blacklist system with a API that will kick all the players that have a specific role in the group. I have the group info that the API prints out:
▼ {
["groupId"] = 32071710,
["roles"] = ▼ {
[1] = ▶ {...},
[2] = ▼ {
["id"] = 97174268,
["memberCount"] = 9,
["name"] = "GUARD ENTRANCE PROGRAM",
["rank"] = 1
},
[3] = ▼ {
["id"] = 97195676,
["memberCount"] = 3,
["name"] = "OSUT",
["rank"] = 2
},
[4] = ▶ {...},
[5] = ▶ {...},
[6] = ▶ {...},
[7] = ▶ {...},
[8] = ▶ {...},
[9] = ▶ {...},
[10] = ▶ {...},
[11] = ▶ {...},
[12] = ▶ {...},
[13] = ▶ {...},
[14] = ▶ {...},
[15] = ▶ {...}
}
The opened ones are the ones I wanna kick out of the game. Here is my script:
local HttpService = game:GetService("HttpService")
local rolesAPI = "https://groups.roproxy.com/v1/groups/32071710/roles"
local blacklistedRoleIds = {97174268, 97195676} -- Role IDs to blacklist
local function getGroupRoles()
local success, result = pcall(function()
return HttpService:GetAsync(rolesAPI)
end)
if success then
return HttpService:JSONDecode(result)
else
warn("Failed to fetch group roles:", result)
return nil
end
end
game.Players.PlayerAdded:Connect(function(player)
local groupRoles = getGroupRoles()
if groupRoles then
print(groupRoles)
local playerRoleId = groupRoles[tostring(player.UserId)]
if playerRoleId and table.find(blacklistedRoleIds, playerRoleId.id) then
print(player.Name .. " is blacklisted.")
player:Kick("You are blacklisted from this group.")
end
end
end)
The problem is it doesnt kick the player.
id appreaciate any help.