I’m trying to have a function to retrieve a player’s rank number in a group with a function and then use that data to create a PlayerData folder with a bunch of essential data for a custom leaderboard Gui.
This is the function:
The issue is that the script says people who are in the group and have been in the group long before they joined, are not in the group. Also, if the people who are affected rejoin the game, the issue still happens to them.
I’ve had multiple friends of mine who are very good scripters look over the entire module and they couldn’t figure out the issue.
Have you tried the function without the protected call or tried to retrieve the error and printing it? It should give some insight as to why the function isn’t working.
function getRankInGroup(player, group)
local groupRank
local success, err = pcall(function()
groupRank = player:GetRankInGroup(group)
end)
if not success then
print(err)
end
return groupRank
end
and see if there are any errors
I pressed send reply by accident, don’t care about (post withdrawn by author, will be automatically deleted in 1 hour unless flagged)
It would be useful if you could also show us where you call the function. It is entirely possible that you could be calling it using the PlayerId, or name, instead of the Player instance.
Example on how the function should be called
local player = game.Players.Someone
local group = 12345678
local rank = GetRankInGroup(player, group)
And as said above, try adding an error handler, as it will allow you to figure out the cause.