Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I get a players rank in group if they are not in game?

As you know you can not send requests to roblox's api from game. And I need to get a players rank in group based off ID. How do I do this?

I have tried

HttpService:GetAsync("https://groups.rprxy.xyz/v1/users/"..tostring(UserId).."/groups/roles")

It returned 400(Bad Request)

1 answer

Only use this when you have a player not in game who's rank you want to check, otherwise use player:GetRankInGroup()

The reason it isn't working is because the link you're trying to get is invalid. Try pasting it into your browser and you'll see that it'll return this error code:

{"errors":[{"code":0,"message":"Something went wrong with the request, see response status code."}]}

the api you're looking for is http://api.rprxy.xyz/users/UserId_Goes_Here/groups

#Code Example

local HttpService = game:GetService("HttpService")
local userId = 20111088
local groupToLookFor = "Splatoon"
local isInGroup = false

local response = HttpService:GetAsync("http://api.rprxy.xyz/users/" .. userId .. "/groups")
local playersGroups =HttpService:JSONDecode(response)


--go through each group to see if the user is in the `groupToLookFor` group.
for _, group in pairs(playersGroups) do
    if group.Name == groupToLookFor then 
        isInGroup = true
	print("players rank in group: ", group.Rank)
	return
    end 
end


--[[
    This code goes through each group the player's in and prints out the group info.
    We don't need it, but it's good to see what's inside the table.

    for _, group in pairs(playersGroups) do
        for index, value in pairs(group)do
            print(index, value)
        end
    end
]]

2 comments

0

I just realized I misread the title. You want to check their rank in the group. I edited so it'll do that

0

pls respond

This discussion is preserved as it was. New answers, comments, and votes are closed.