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):
local ranks = { Student = { XPneeded = 0; Rank = 1; }; Janitor = { XPneeded = 100; Rank = 2 }; CafeteriaHelper = { XPneeded = 150; Rank = 3; }; Teacher = { XPneeded = 220; Rank = 4; }; Nurse = { XPneeded = 280; Rank = 5; }; Secretary = { XPneeded = 350; Rank = 6; }; Principal = { XPneeded = 500; Rank = 7; }; }
And this is the rank function (in module script):
function module.giveXPOrRankPlayer(plr,amount) -- Pop up local gui = game.ReplicatedStorage.UI.GainNotif:Clone() gui.Parent = plr.PlayerGui gui.TextLabel.Text = "+"..amount.." XP" gui.FireTweenAndTrans:FireClient(plr) -- Rank and XP stuff plr.Value = plr.Value + amount print(plr.Name.." has been given "..amount.." XP") for i, rank in pairs(ranks) do if plr.XP.Value >= rank.XPneeded then if ranks[i] == plr.Rank.Value then local nextRank = i+1 plr.Rank = ranks[nextRank] local converted = tostring(rank) print(plr.Name.." has ranked up to "..converted..", "..plr.XP.Value.." XP") end end end end
Why doesn't the script increase the value/xp?
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.