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

Looking for a shorter method to do do this script? Please help!

Asked by
Hizar7 102
6 years ago

hey guys, do you have an opinion on an easier way to do this script ? where i down need to repeat it every line on a new level reached to change hp? Thanks!

while true do
            wait(.5)
if player.Points.Level.Value == 1 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +1 
else 
if player.Points.Level.Value == 2 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +2 
else 
if player.Points.Level.Value == 3 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +3 
else 
if player.Points.Level.Value == 4 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +4 
else 
if player.Points.Level.Value == 5 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +5
else 
if player.Points.Level.Value == 6 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +6 
else 
if player.Points.Level.Value == 7 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +7 
else 
if player.Points.Level.Value == 8 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +8 
else 
if player.Points.Level.Value == 9 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +9 
else 
if player.Points.Level.Value == 10 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +10 
else 
if player.Points.Level.Value == 15 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +15 
else 
if player.Points.Level.Value == 20 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +20 
else 
if player.Points.Level.Value == 25 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +25 
else 
if player.Points.Level.Value == 30 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +33 
else 
if player.Points.Level.Value == 35 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +38 
else 
if player.Points.Level.Value == 40 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +43 
else 
if player.Points.Level.Value == 45 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +48 
else 
if player.Points.Level.Value == 50 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +55 
else 
if player.Points.Level.Value == 55 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +60 
else 
if player.Points.Level.Value == 60 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +65 
else 
if player.Points.Level.Value == 65 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +70 
else 
if player.Points.Level.Value == 70 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +75 
else 
if player.Points.Level.Value == 75 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +80 
else 
if player.Points.Level.Value == 80 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +85 
else 
if player.Points.Level.Value == 85 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +90 
else 
if player.Points.Level.Value == 90 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +95 
else 
if player.Points.Level.Value == 95 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +100 
else 
if player.Points.Level.Value == 100 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +110 
else 
if player.Points.Level.Value == 105 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +120 
else 
if player.Points.Level.Value == 110 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +130 
else 
if player.Points.Level.Value == 115 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +140 
else 
if player.Points.Level.Value == 120 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +150 
else 
if player.Points.Level.Value == 125 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +160 
else 
if player.Points.Level.Value == 130 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +170 
else 
if player.Points.Level.Value == 135 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +180 
else 
if player.Points.Level.Value == 140 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +190 
else 
if player.Points.Level.Value == 150 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +195 
else 
if player.Points.Level.Value == 151 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +196 
else 
if player.Points.Level.Value == 152 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +197 
else 
if player.Points.Level.Value == 153 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +198 
else 
if player.Points.Level.Value == 154 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +199 
else 
if player.Points.Level.Value == 155 then  
   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +200    
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end   
end
end
    end)
end)

0
lol Hizar7 102 — 6y
0
dear lord User#19524 175 — 6y
0
Use elseif Odawg566 9 — 6y
0
yeah i can use elseif but id rather have something that could not make me type all this out lol Hizar7 102 — 6y
View all comments (2 more)
0
elseif would remove all the ends Odawg566 9 — 6y
0
I am really looking for a function basically on level.Changed:Connect, but also if there is something like MaxHealth.Value = level.Value + 100 * 1.1 or something Hizar7 102 — 6y

2 answers

Log in to vote
2
Answered by
crywink 419 Moderation Voter
6 years ago

Hey there,

From what I see so far, you're trying to set the MaxHealth to the player.Health.StoredMaxHealth.Value + player.Points.Level.Value.

If you wanted to do this without all that code, it would look like this.

while true do
    wait(.5)
    player.Character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value + player.Points.Level.Value
end

Just leave a comment if this isn't exactly what you want or you're having any trouble.

If this was helpful remember to accept and upvote the answer.

0
Also - since this script is all about improving efficiency, and no condition needs to be met for the while loop (infinite), we can move to while wait(.5) do over while true do. SummerEquinox 643 — 6y
0
Your comment makes no sense. Moving the wait() as the condition of a loop does NOT make the loop any more efficiency. There is no immediate efficiency requirement this script needs. Your method is just another horrible method. Zafirua 1348 — 6y
Ad
Log in to vote
-1
Answered by
Zripple 18
6 years ago
pointlevel = player.Points.Level.Value
humanhealth = player.character.Humanoid.MaxHealth
storedhealth = player.Health.StoredMaxHealth.Value

while true do
wait(.5)
if pointlevel == 1 then
    humanhealth = storedhealth +1
else

etc... continue the script on, changing the numbers. I was in a hurry and there is a way better way to do this.

Answer this question