game.Players.PlayerAdded:Connect(function(plr) plr:WaitForChild("stats") plr:WaitForChild("leaderstats") plr.stats:WaitForChild("exp") plr.leaderstats:WaitForChild("level") local l = plr.leaderstats.level local e = plr.stats.exp while true do if e.Value >= 50 then l.Value = l.Value +1 wait(1) end end end)
it wont make me level up when correct exp reached help?
Here is the fix for what you want using a text button:
-- Normal script: script.Parent.LevelUp.OnServerEvent:Connect(function() -- Im using a remote even btw local plr = script.Parent.Parent.Parent if plr.exp.Value >= 50 then plr.leaderstats.Level.Value = plr.leaderstats.Level.Value + 1 plr.exp.Value = plr.exp.Value - 50 elseif plr.exp.Value < 50 then -- do nothing end end) -- Local script to fire upon clicking: script.Parent.MouseButton1Click:Connect(function() script.Parent.Parent.LevelUp:FireServer() end)
The problem with your script is
1: you're not getting the player correctly.
2: "stats" is a reserved word, meaning the server thinks it's something else.
my suggestions:
1: get the player through "script.parent" method
2: make the exp's parent the player not a folder.