Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 5 years ago

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
0
thats a very good question RodrigatorOP 172 — 5y
0
just like mine so go check it out in questions look for my name and big chungus RodrigatorOP 172 — 5y
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? turtle2004 167 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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.

Ad

Answer this question