Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I make it so that if XP reaches a surtent value, it will award a rank?

Asked by 3 years ago

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!

for i, v in pairs(game.Players:GetPlayers()) do
    if v.experience.Value == 50 then
        v.leaderstats.Rank.Value = 'Private'
    end
end
0
thats only gonna run once :/ spectsy 16 — 3y
0
Ok, how to fix it? :/ PufferfishDev 49 — 3y
0
maybe run it when a player ranks up? spectsy 16 — 3y
0
how? PufferfishDev 49 — 3y
0
GetPropertyChangedSignal? PufferfishDev 49 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

Use :GetPropertyChangedSignal("Value", instance) on the XP value.

Documentation

In the future, please provide more code. I.E your full leaderstats script or XP system. If this helped, mark it as a solution!

Ad
Log in to vote
0
Answered by 3 years ago

Next time please provide more code.

game.Players.PlayerAdded:Connect(function(player)--Fired when the player is added into the game
    local Experience = player:WaitForChild("experience")--The Experience variable
    local Rank = player:WaitForChild("leaderstats"):WaitForChild("Rank")--The Rank variable
    Experience.Changed:Connect(function()--Fired when the value is changed
        if Experience.Value == 50 then--Checks if the Experience is equal to 50
            Rank.Value = "Private"--Rank is now set to Private
        end
    end)
end)

Answer this question