So this leader board script isn't working and I don't know why. This is a normal script located in Workspace.
scoreKey = "PlayerScore"
game.Players.PlayerAdded:connect(function(player)
if player:WaitForDataReady() then
local leaderstats = Instance.new("IntValue")
leaderstats.Name = "leaderstats"
local rank = Instance.new("StringValue")
rank.Name = "Rank"
rank.Value = player:GetRoleInGroup(1241633)
local score = Instance.new("IntValue")
score.Name = "Points"
score.Value = player:LoadNumber(scoreKey)
leaderstats.Parent = player
rank.Parent = leaderstats
score.Parent = leaderstats
end
end)
game.Players.PlayerRemoving:connect(function(player)
if player:FindFirstChild("leaderstats") then
player:SaveNumber(scoreKey, player.leaderstats.Points.Value)
end
end)

2 comments
Try it without the "if player:WaitForDataReady()" and see if that's the problem.
Don't use DataPersistence. It's 2016 m8. No one uses that anymore. Use DataStores.