How do I get username information based off a player that holds a specific group rank id?
What I’m trying to do is create offices, and have the player’s username that holds a specific rolesetid to display on that office’s textlabel (To save the time of changing it when they’re removed from their position.) So if they get promoted/demoted, it will automatically remove them from that textlabel and replace it with vacant or a new person that holds the given rolesetid.
I’ve looked it up, and the current third party api i’ve been using is roproxy.com but it hasn’t been working. Does anyone know what I should do?
Here’s the script:
local Players = game:GetService("Players")
local groupId = 5879110
local targetRankId = 255
local textLabel = script.Parent
local function updateTextLabel()
local url = string.format("https://groups.roproxy.com/v1/groups/%d/roles/%d/users", groupId, targetRankId)
local success, response = pcall(HttpService.GetAsync, HttpService, url)
if success then
print("Status code:", response.StatusCode)
print("Response body:", response.Body)
local data = HttpService:JSONDecode(response.Body)
if data and data.data then
local usernames = {}
for _, member in ipairs(data.data) do
local username = Players:GetNameFromUserIdAsync(member.id)
table.insert(usernames, username)
end
textLabel.Text = table.concat(usernames, ", ")
else
warn("Failed to decode group data.")
end
else
warn("HTTP request failed:", response)
end
end
updateTextLabel()```