--working game.Players.PlayerAdded:Connect(function(plr) wait() plr.Chatted:connect(function(msg) if msg == "/e dance" or msg == "/e dance2" or msg == "/e dance3" then plr.leaderstats.XP.Value = plr.leaderstats.XP.Value + plr.leaderstats.Levels.Value repeat plr.leaderstats.XP.Value = plr.leaderstats.XP.Value + 10 wait(5) until plr.Character.HumanoidRootPart.Velocity.Magnitude >= 2 end end) --not working below while plr.leaderstats.XP.Value >= 100 do game.ReplicatedStorage.LevelUp:FireServer() break end end)
what bad i did?
Hello, gloveshun!
You can check once a value has went above your selected value using the changed event. This event will fire everytime a value has changed. Also, you wouldn't need a remote to give the player a level as this is in a normal script.
UPDATED SCRIPT:
game.Players.PlayerAdded:Connect(function(plr) plr.leaderstats.XP.Changed:Connect(function(NewValue) if NewValue >= 100 then plr:WaitForChild("leaderstats").Levels.Value = plr:WaitForChild("leaderstats").Levels.Value + 1 end end) plr.Chatted:connect(function(msg) if msg == "/e dance" or msg == "/e dance2" or msg == "/e dance3" then plr.leaderstats.XP.Value = plr.leaderstats.XP.Value + plr.leaderstats.Levels.Value repeat plr.leaderstats.XP.Value = plr.leaderstats.XP.Value + 10 wait(5) until plr.Character.HumanoidRootPart.Velocity.Magnitude >= 2 end end) end)