I’m trying to get users in a selected role with HttpService, but it errors with “HTTP 400 (Bad Request)” so how would I fix this or do this differently?
local HttpService = game:GetService("HttpService")
local response = HttpService:JSONDecode(
HttpService:GetAsync("https://groups.rprxy.xyz/v1/groups/4585564/roles/255/users?limit=10&sortOrder=Asc")
)
Also tried searching the Developer Forum but none of the topics helped.
I don’t think you even need to use HttpService. You can check if a player is in a group or is a certain rank without any services. Example:
local rank = 0 -- The rank the player will need to get through
local groupID = 0 -- The group ID the player must be in
local character = game.Players.LocalPlayer
if (character:IsInGroup(groupID) and character:GetRankInGroup(groupID) == rank) then
print("The player is the correct rank.")
end
Just if you’re wondering, yes, I did test this. It works fine.
local HttpService = game:GetService("HttpService")
function GetUsersInRank(groupId, rankNumber)
local rankIds = HttpService:JSONDecode(
HttpService:GetAsync("https://groups.rprxy.xyz/v1/groups/"..groupId.."/roles")
)
if rankIds.roles == nil then
warn("Something went wrong")
return
end
for i, v in ipairs(rankIds.roles) do
if v.rank == rankNumber then
return HttpService:JSONDecode(
HttpService:GetAsync("https://groups.rprxy.xyz/v1/groups/"..groupId.."/roles/"..v.id.."/users?limit=100&sortOrder=Asc")
).data
end
end
return nil
end
print(GetUsersInRank(4585564, 255))
Basically, ranks have an id behind them like an asset id. This id is not the same as the rank number. This id is a unique identifier across the platform and will only ever identify that one role.
Also is it possible to get the result by only using GetAsync once since you can only send 500 HTTP requests a minute and you might be doing other things with HttpService?