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!

001while true do
002            wait(.5)
003if player.Points.Level.Value == 1 then 
004   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +1
005else
006if player.Points.Level.Value == 2 then 
007   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +2
008else
009if player.Points.Level.Value == 3 then 
010   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +3
011else
012if player.Points.Level.Value == 4 then 
013   player.character.Humanoid.MaxHealth = player.Health.StoredMaxHealth.Value +4
014else
015if player.Points.Level.Value == 5 then 
View all 172 lines...
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.

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

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
1pointlevel = player.Points.Level.Value
2humanhealth = player.character.Humanoid.MaxHealth
3storedhealth = player.Health.StoredMaxHealth.Value
4 
5while true do
6wait(.5)
7if pointlevel == 1 then
8    humanhealth = storedhealth +1
9else

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