So this is my code for my game
game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder", player) leaderstats.Name = "leaderstats" local EXP = Instance.new("NumberValue", leaderstats) EXP.Name = "EXP" local Lvl = Instance.new("NumberValue", leaderstats) Lvl.Name = "Level" Lvl.Value = 1 local MaxEXP = 100 * (Lvl.Value / 2) game.ServerStorage.GiveExp.Event:Connect(function(amount,plr) if player.Name == plr.Name then EXP.Value = EXP.Value + amount end end) EXP:GetPropertyChangedSignal("Value"):Connect(function() if EXP.Value >= MaxEXP.Value then EXP.Value - MaxEXP.Value Lvl.Value = Lvl.Value + 1 end end) end)
and its saying this segment is wrong
EXP.Value - MaxEXP.Value
I don't really understand why it's doing that and how to fix it
This is because you’re performing a blank arithmetic. To actively modify a state, you have to apply the =
assign operator.
EXP.Value = (EXP.Value - MaxEXP.Value)