exp.Changed:Connect(function() if exp.Value >= required_exp.Value then exp.Value -= required_exp.Value level.Value += 1 required_exp.Value = level.Value * 100 Player.Character.Humanoid.MaxHealth += 4 end end)
For no reason at all this code does not work with large numbers, it has worked perfectly fine with no issues from other methods of getting XP within the game. But when I decided to add a code system that grants 1k XP using a code it suddenly breaks. I've read about this issue in which its due to the value infinitely changing within the function but I absolutely fail to see how it would infinitely loop due to me changing the value up until the exp value is less than the required xp value. it somehow creates xp out of nowhere with my system you should end up at lvl 5 but instead im somehow at lvl 9 even though lvl 5-6 have more xp requirements combined than what is given.
Use exp:GetPropertyChangedSignal("Value"):Connect(function()
because it saves on resources
In the script you change the xp value, which triggers the script to fire again which changes the xp again, which causes it to trigger over and over again and exceed the limit.