Ok so when the experience is greater than or equal to the needed experience, it is suppose to increase the players level by 1, and subtract the needed experience to level up from the experience. In other words, say the experience that is needed to level up is 2450, if the player had gained 2452 experience, this should result in a remainder of 2 experience points. What it does instead is go to -2448.
ServerScript
RemoteEvents.LevelCap.OnServerEvent:Connect(function(Player, Stat)
local Data = Player.Persistance:WaitForChild("Data")
if Data.Experience.Value >= Data.ExperienceNeeded.Value then
wait(0.5)
Data.Experience.Value = (Data.Experience.Value - Data.ExperienceNeeded.Value)
wait(0.5)
Data.ExperienceNeeded.Value = (Data.Level.Value * 50)
Data.Level.Value = Data.Level.Value + 1
end
end)
LocalScript
local Player = game.Players.LocalPlayer
repeat wait() until Player.Character ~= nil
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvents = ReplicatedStorage.RemoteEvents
local Data = Player.Persistance:WaitForChild("Data")
local pcall function StatChange()
RemoteEvents.LevelCap:FireServer("Experience")
print("Hello")
end
Data.Experience.Changed:Connect(StatChange)
it does level up the player, but the experience just inverts.

3 comments
I think that is why you are subtracting "Data.Experience.Value = (Data.Experience.Value - Data.ExperienceNeeded.Value)"
Turns out that 2452 - 2450 = 2. Subtract 2450 again and you get 2448. It seems my problem is not that it is inverting, but because it is running that line twice.
The needed value is 2450. The experience is at 2452 so that would mean a level up with 2 remainder exp. But it seems that line 7 is running twice.