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

Script is not increasing a value and doing as it should, with no errors?

Asked by
CodeWon 181
3 years ago

I tried making a ranking system, and the script is supposed to increase a value in the player called "xp"

These are the ranks (they might have to do with the error):

01local ranks = {
02    Student = {
03        XPneeded = 0;
04        Rank = 1;
05    };
06    Janitor = {
07        XPneeded = 100;
08        Rank = 2
09    };
10    CafeteriaHelper = {
11        XPneeded = 150;
12        Rank = 3;
13    };
14    Teacher = {
15        XPneeded = 220;
View all 30 lines...

And this is the rank function (in module script):

01function module.giveXPOrRankPlayer(plr,amount)
02    -- Pop up
03    local gui = game.ReplicatedStorage.UI.GainNotif:Clone()
04    gui.Parent = plr.PlayerGui
05    gui.TextLabel.Text = "+"..amount.." XP"
06    gui.FireTweenAndTrans:FireClient(plr)
07    -- Rank and XP stuff
08    plr.Value = plr.Value + amount
09    print(plr.Name.." has been given "..amount.." XP")
10    for i, rank in pairs(ranks) do
11        if plr.XP.Value >= rank.XPneeded then
12            if ranks[i] == plr.Rank.Value then
13                local nextRank = i+1
14                plr.Rank = ranks[nextRank]
15 
View all 21 lines...

Why doesn't the script increase the value/xp?

1 answer

Log in to vote
1
Answered by 3 years ago

plr.Value = plr.Value + amount, Line number 8 should have plr.Exp.Value += amount. You just accidently forgot to specify the Exp as the value your changing.

0
Ohhh I didn't realize that! CodeWon 181 — 3y
Ad

Answer this question