Hello, basically I’m trying to make a leveling system using String Values. So everytime you level up, you get a new rank. E.g, Junior Manager, Manager, Senior Manager, etc.
My problem is that this isn’t working. The system works up to the second rank but then stops going forward. To get to the second rank, you need 10 xp, but then for the third, you need 15. So the system will reset the counter back to 0 everytime you get 10 xp, even when that’s not the requirement.
game.Players.PlayerAdded:Connect(function(player)
local rank = Instance.new('StringValue', player)
rank.Name = 'Level'
rank.Value = 'Cadet'
rank.Parent = player
local exp = Instance.new('IntValue', rank)
exp.Name = 'Loyalty'
exp.Value = 0
local maxExp = Instance.new('IntValue', rank)
maxExp.Name = "Max"
maxExp.Value = 10
exp.Changed:Connect(function(val)
if exp.Value == 15 then
rank.Value = 'Private First Class'
exp.Value = 0
maxExp.Value = 20
elseif
exp.Value == 10 then
rank.Value = 'Private'
exp.Value = 0
maxExp.Value = 15
end
end)
end)
I’ve tried changing the exp.Changed:Connect(function(val)
to exp.GetPropertyChangedSignal("Value")
but that just breaks the entire script. I’ve tried moving around the positions of the code in the script, but nothing seems to be working. Any help is greatly appreciated.