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 4 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!

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

2 answers

Log in to vote
0
Answered by 4 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 4 years ago

Next time please provide more code.

1game.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)
9end)

Answer this question