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

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

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)

6 comments

0

lol

0

dear lord

0

Use elseif

0

yeah i can use elseif but id rather have something that could not make me type all this out lol

0

elseif would remove all the ends

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

2 answers

✓ Accepted answer

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.

2 comments

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.

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.

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.

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