Hi. I have made a rank system but I can't find a proper way to make it award a rank with XP. (Yes, experience is NOT located in leaderstats since it's meant to be hidden.) Here is my code, please help!
1 | for i, v in pairs (game.Players:GetPlayers()) do |
2 | if v.experience.Value = = 50 then |
3 | v.leaderstats.Rank.Value = 'Private' |
4 | end |
5 | end |
Use :GetPropertyChangedSignal("Value", instance) on the XP value.
In the future, please provide more code. I.E your full leaderstats script or XP system. If this helped, mark it as a solution!
Next time please provide more code.
1 | game.Players.PlayerAdded:Connect( function (player) --Fired when the player is added into the game |
2 | local Experience = player:WaitForChild( "experience" ) --The Experience variable |
3 | local Rank = player:WaitForChild( "leaderstats" ):WaitForChild( "Rank" ) --The Rank variable |
4 | Experience.Changed:Connect( function () --Fired when the value is changed |
5 | if Experience.Value = = 50 then --Checks if the Experience is equal to 50 |
6 | Rank.Value = "Private" --Rank is now set to Private |
7 | end |
8 | end ) |
9 | end ) |