I have a script that prints out a whole group in a table. As shown below:
print("Group name: Nighthawk Reaper Battalion")
local HttpService = game:GetService("HttpService")
local groupId = "4734688" --7581138
local URL = "https://groups.rprxy.xyz/v1/groups/" .. groupId .. "/users?sortOrder=Asc&limit=100"
local gottenPlayers = {}
local data
local response
local nextPage
local function getData()
if nextPage then
local s = pcall(function ()
response = HttpService:GetAsync(URL .. "&cursor=" .. nextPage)
data = HttpService:JSONDecode(response)
end)
return s
else
local s = pcall(function ()
response = HttpService:GetAsync(URL)
data = HttpService:JSONDecode(response)
end)
return s
end
end
while wait() do
if getData() then
local users = data["data"]
nextPage = data["nextPageCursor"]
print("Requesting NRB Info")
for i,v in ipairs(users) do
local username = v["user"]["username"]
local userid = v["user"]["userId"]
table.insert(gottenPlayers, {username = username, userid = userid })
end
if not nextPage then
break
end
else
print("Something went wrong")
break
end
end
print(gottenPlayers)
What I need help with is how to use GetRankInGroup(Group ID) with the user id in the table to see if they have a rank in another group and print a message if they are.
What I want is to go through each ID in the table to see if any are in a specific group. Using GetRankInGroup(Group ID) as apparently that is the easiest way.
You would then need to loop through the response, checking the group id and if it is equal to the group id you’re looking for. Please note however with a dataset potentially as large as a whole entire group which I believe you’re wanting to run through, you’re likely to hit rate limits.
getrank in group is a function of player.
but if i understand corretly the player you want to check might not be in game
and it is only one other group you want to check
a posible solution is to get a simulair table of that other group (and see if the Id pops up in both)
here i advice GetGroupsAsync.
this prints a table of all the groups a player is a part of. without the player having to be in game
then you can check if the other group is in that table
local GroupService = game:GetService("GroupService")
for _, player in pairs(gottenPlayers) do
local playerGroups = GroupService:GetGroupsAsync(player.userid)
end
player in this for loop will be each individual object for each player within your gottenPlayers table, your object looking something like this: {userid = 1, username = 'Foo'}
playerGroups will return an object containing some information about the group, namely the group id which you’re after.