Help with rank leaderboard

I am currently making a rank leaderboard. It works when I am testing, but when I join the game, it says “Guest”. Here is the script
game.Players.PlayerAdded:Connect(function(Player))

local leaderstats = Instance.new(“IntValue”)

leaderstats .Name = “leaderstats”

local Rank = Instance.new(“IntValue”)

Rank.Name = “Rank”

Rank.Value = Player:GetRankInGroup(11049508)

Rank.Parent = stats

leaderstats.Parent = Player

end)

Hi, @Maenaryz. Here is what I would use when I add a rank leaderboard

game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder",player)
leaderstats.Name = "leaderstats"
local GroupId = 11049508

local Rank = Instance.new("StringValue", leaderstats)
Rank.Name = "Rank"
Rank.Value = player:GetRoleInGroup(GroupId)
Rank.Parent = leaderstats

Thanks so much, but I forgot to update, after looking at a few tutorials, I already figured it out, have a wonderful day!

Ok, glad you figured it out! Hope you have a great day too.

This is building support not scripting just a fyi, probably check which category you are posting it in.