Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is there a way to level a player up more efficiently?

Is there a more efficient way to level up a player than just doing the same line of code over and over and over? EX:

while true do
	wait(.1)
if p:WaitForChild("leaderstats").EXP.Value >= 100 then
	script.Parent.Level.Text = 10
	wait(2)
	break
end
end

while true do
	wait(.1)
if p:WaitForChild("leaderstats").EXP.Value >= 200 then
	script.Parent.Level.Text = 11
	wait(2)
	break
end
end

3 comments

0

thats a very good question

0

just like mine so go check it out in questions look for my name and big chungus

0

There's no need for two while loops, it can be done in one, also think about it, do you really need to check every tenth of a second?

1 answer

✓ Accepted answer

If you would like to add 100 XP or any amount to get to the next level every time, use this:

while wait(.1) do --saving one line by putting wait here
      local LevelUpValue = 100 
      local CurrentLevel = 10
      if p:WaitForChild("leaderstats").EXP.Value >= LevelUpValue then
            script.Parent.Level.Text = CurrentLevel 
            LevelUpValue = LevelUpValue + 100 --add amount of xp you can multiply though
            CurrentLevel = CurrentLevel + 1 --add level
      end
end

I hope this works for you, because I had to do something like this once and it worked for me.

This discussion is preserved as it was. New answers, comments, and votes are closed.