Help with blacklisting certain roles with group API

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.

1 Like

So basic debug skills here, but right now that’s not much information.

  1. Does it print the group roles?

  2. Does it print “playerName is blacklisted”

If not, for #2 then you know it’s an issue with either: playerRoleId or table.find(blacklistedRoleIds, playerRoleId.id)

1 Like

I see the issue actually…

Your api is requesting: The Group Roles

And then your trying to find a specific player’s rank which obviously won’t be listed in the Group roles.

ALSO There is absolutely no point to the API because:

  • Roblox has the player:IsInGroup(groupId), player:GetRoleInGroup(groupId), player:GetRankInGroup(groupId) API built into roblox.PLEASE USE THAT it’s 10x more efficient than sending and using up an HTTP request to a proxy which sends and returns a fetch to Roblox API.
1 Like

Adding on to this, Roblox has GroupService:GetGroupInfo() that returns this exact information. Here is the page for it:

Here is an example return:

group = {
    Name = "Knights of the Seventh Sanctum",
    Id = 377251,
    Owner = {
        Name = "Vilicus",
        Id = 23415609
    },
    EmblemUrl = "http://www.roblox.com/asset/?id=60428602",
    Description = "We fight alongside the balance to make sure no one becomes to powerful",
    Roles = {
        [1] = {
            Name = "Apprentice",
            Rank = 1
        },
        [2] = {
            Name = "Warrior",
            Rank = 2
        },
        [3] = {
            Name = "Earth Walker",
            Rank = 255
        }
    }
}

Using HTTPs adds a whole other level of complexity. It shouldn’t be used if Roblox already provides the functionality.

Basically do:

local GroupService = game:GetService("GroupService")

local GROUP_ID = 32071710

local roles
local success, errorMessage = pcall(function()
    roles = GroupService:GetGroupInfoAsync(GROUP_ID).Roles
end)
if not success then
    print(errorMessage)
    -- Handle the error, for example retry a few times (recommended) or just give up and kick the player (not recommended)
end

-- TODO: Your PlayerAdded connection here using the roles table above (unless getting the roles table failed)

Exactly, infact Roblox disabled same server requests for this reason
@ResoluteSX
There is no need, nor will roblox want you or allow you (not using a proxy) to send a request for the same data that is natively fetched.

Don’t try and overcomplicate code, most of the times the simplest solutions are the best.

1 Like

Doesn’t roproxy still work?

I meant that roblox won’t allow same server requests through HTTP unless you use a proxy.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.