First of all using a while loop is a bad idea, your local script should be changed to:
local Player = game.Players.LocalPlayer
local lvl = Player:WaitForChild("Level")
lvl.Changed:Connect(function()
game.replicatedstorage.remotes.update:FireServer(Player)
end)
Let me explain, value objects .Changed method is unique compared to others because using .Changed on other type of instances will detect a change in any property, however when using ValueInstances it will only fire for changes on the Value property
If you remove the .Value from where you are setting the value of the RXP like what @Valkyrop said I’m pretty sure that will just redefine the variable, however if you change the variable like what I said in my first post and keep the .Value where you set the RXP, it should work.
local Level = PlayerFolder.Level.Value
to
local Level = PlayerFolder.Level
and
if Level < 5 and Level > 1 then
to
if Level.Value < 5 and Level.Value > 1 then
Will not update the Value, the Val variable does not point to the property itself it obtains the value and points to the number, so if the value IntValue.Value is 50, then its the same as saying local Val = 50
then putting Val = 10, it doesn’t actually update IntValue, what you have to do is
local Value = IntValue
Value.Value = 10
This will reference the Instance’s property allowing it to edit the Value.
Try removing the ‘.Value’ from this line, because in all those if statements your trying to set the value of a number, instead of the IntValue called ‘RequiredXP’, and a number doesn’t have a ‘.Value’ property.
I just found the solution, the problem was that the remote was fired too many times every seconds so I replaced the local script with this :
local Player = game.Players.LocalPlayer
local lvl = Player.PlayerFolder:WaitForChild("Level")
lvl.Changed:Connect(function()
game.ReplicatedStorage.Remotes.Update:FireServer(Player)
end)
Thank you guys for all the help, you really helped me !