So basically, I want to set the requirement value without changing the level value.
Sounds confusing right?
As you can see, the level value is assuming the value of the requirement variable, which I don’t want it to do.
And for some reason, there’s a 50% chance of this happening which makes it even weirder
What the hell is going on
What parameter would even be for exp.Changed?
I’m honestly really confused and fed up with scripts just not working as they should
Why is it changing the value, I’ve tried everything
You might be getting a race condition with the changed event changing itself.
Each time the exp.Value is changed it triggers a new event, depending on how these are scheduled to run they might be running before the values have been updated elsewhere.
Try moving all theexp.Value = something parts of your code to the end of their codeblocks.
It looks like you’re trying to detect if the value of exp is changed to know when you’re supposed to level up, so I believe you just need to use exp.Changed:Connect(function(Value)
At first it levelled me up by 10 more levels than it should have, worked properly and then all of a sudden I was level 701
It’s definitely an improvement from before but not quite there
Oh yeah, I forgot to look at how you negate xp per level up. You did the xp negation wrong. Instead it should be more like this:
if exp.Value >= Requirement.Value then
level.Value += 1
levelvalue = level.Value
exp.Value -= Requirement.Value
Requirement.Value = levelvalue * 25
end
You don’t need to add the elseif statement because it does the same thing in the if statement above. This method will keep the exp value and not reset it.
I hope this helps out!
Edit: The second code sample is quite wrong so I decided to remove it.