I own about 7 groups but this code that I am trying is returning a 0/nil value, everytime I try to do it.
local function ownership(userId)
local gs = game:GetService("GroupService")
local groups = gs:GetGroupsAsync(userId)
local groupsminrank = {}
for _, v in pairs(groups) do
local groupInfo = gs:GetGroupInfoAsync(v.Id)
local roles = groupInfo.Roles
if roles and roles[255] then
local minRank = roles[255].Rank
print("Group:", v.Name, "Player Rank:", v.Rank, "Min Rank:", minRank)
if v.Rank >= minRank then
table.insert(groupsminrank, v.Id)
end
end
end
print(#groupsminrank)
return #groupsminrank
end
local ownership = ownership(player.UserId)
print(ownership)```