Why doesn't this script work?

So I am making a level system and I wanted the exp of the player to reset when it reaches a certain amount of EXP.

Unfortunately it’s not working.
There are no errors in script I did some printing and it prints too.
Now what is the problem?

game.Players.PlayerAdded:Connect(function(plr)
	wait(.1)
	local exp = plr.PlayerItems.EXP
	local levels = plr.PlayerItems.Level
	
	while wait() do
		if exp.Value >= (100 * (levels.Value + 1)) then
			levels.Value = levels.Value + 1
			exp.Value = 0
			game.ReplicatedStorage.LevelUpGui:FireClient(plr)
		end
	end
end)	

I’m going to sleep now :sleeping:
Soo please give me a answer before I wake up tomorrow.
So Please :pleading_face: ?

Good night all :night_with_stars:

1 Like

Don’t use a loop for that use a .Changed event. The problem might be in the LocalScript you are firing the remote to.

2 Likes

Sorry for the late reply but the thing was that I did a PlayerAddedEvent inside a PlayerAddedEvent and I tried to increase the leaderstats with a localscript