Issue with trying to set value to group rank

Hey everyone, I’ve been trying to make a leaderboard thing put a user’s role in a rank on the leaderboard, though it puts it as “0”.

I’ve tried switching up the values in my code, though it didn’t work out.
Here’s my current full code, help is appreciated:

-- variables
local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("TimeSaveSystem")

local function onPlayerJoin(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
 
	local gold = Instance.new("IntValue")
	gold.Name = "Rank"
	gold.Value = player:GetRoleInGroup(5008838)
	gold.Parent = leaderstats
	
	local mins = Instance.new("IntValue")
	mins.Name = "Minutes"
	mins.Value = ds1:GetAsync(player.UserId) or 0
 ds1:SetAsync(player.UserId, mins.Value)
	mins.Parent = leaderstats
	
	 mins.Changed:connect(function()
  ds1:SetAsync(player.UserId, mins.Value)
	 end)
 
end
 
game.Players.PlayerAdded:Connect(onPlayerJoin)

Any help is appreciated, thank you everyone.

player:GetRoleInGroup() returns the role, not the rank. You should use player:GetRankInGroup() instead.

Hey, thanks for responding, though how can I get it to show the name?
It seems to have showed the ID:
image

Rank is the IntValue between 0 and 255 that sets a Role’s priority in a group. You want to use the Role.
Use a StringValue instead of an IntValue and use player:GetRoleInGroup().

1 Like