I've been trying to create a leveling system using String Values. Basically, everytime you level up, you're given a new rank. E.g, Junior Manager, Manager, senior manager, etc.
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)
Essentially, the problem is that the value changes to 15 like the bottom part of code asks, but it resets everytime when it reaches 10 instead of 15 like I want it to. Visual of error. Because of this, the text label will not change to say "Private First Class". I receive no errors in the output, and I'm completely stumped, any help would be appreciated.
It looks like you don't have rank checking in your script and only just the value checker. To fix that, you can simply do :
exp.Changed:Connect(function(val) if exp.Value == 15 and rank.Value ~= "Private First Class" then -- It checks whether the exp value is 15 and rank value is not equal to Private First Class rank.Value = 'Private First Class' exp.Value = 0 maxExp.Value = 20 elseif exp.Value == 10 and rank.Value ~= "Private" then -- It checks whether the exp value is 10 and rank value is not Private rank.Value = 'Private' exp.Value = 0 maxExp.Value = 15 end end)
Lemme know if it helps!