# Heal player per life percentage

#### mogneto

##### Gureito Eventer
Morning, Night or Evening to all of you!

Well, I was trying to do this script thing and I have a problem here.

\$gameActors.actor(1).gainHp(0.04*(m.mhp));

So I want this script call to heal my actor for 4% of his HP when the script is active. Sadly this doesn't happen
when I use this command, but it happens if I use number values instead, just like this:

\$gameActors.actor(1).gainHp(100);

What did I do wrong?

#### Wavelength

##### MSD Strong
The shortcut for "user" is a, and the shortcut for "target" is b... not m. If you are doing this outside of a battle formula, you need to reference the object (so \$gameActors.actor(1) in your case) rather than use a shortcut.

#### mogneto

##### Gureito Eventer
Mr. Wavelength, you're a god.

What you told me was very helpful. For your contribuition, you've been honored.
Again, you have my thanks.

#### mogneto

##### Gureito Eventer
I'm also trying to round up my heal, because sometimes it comes with decimal values.

tried to do something like this but it didn't work.

var m = \$gameActors.actor(2)

Math.round(\$gameActors.actor(2).gainHp(0.04*(m.mhp)));

##### Veteran
dont use m.mhp on the end, just mhp can do because m.mhp has no strings.
if mhp dont work, use ._mhp, i dont see why you use var though.

#### Wavelength

##### MSD Strong
I'm also trying to round up my heal, because sometimes it comes with decimal values.

tried to do something like this but it didn't work.

var m = \$gameActors.actor(2)

Math.round(\$gameActors.actor(2).gainHp(0.04*(m.mhp)));

It's a logic error. gainHp() doesn't return a value, so you won't be able to round it. Try:

\$gameActors.actor(2).gainHp(Math.round(0.04*(m.mhp)));

or, to ensure you're always rounding up:

\$gameActors.actor(2).gainHp(Math.ceil(0.04*(m.mhp)));

#### mogneto

##### Gureito Eventer
It's a logic error. gainHp() doesn't return a value, so you won't be able to round it. Try:

\$gameActors.actor(2).gainHp(Math.round(0.04*(m.mhp)));

or, to ensure you're always rounding up:

\$gameActors.actor(2).gainHp(Math.ceil(0.04*(m.mhp)));
It worked pretty fine! Thank you all guys!

### Latest Profile Posts

Took our dogs on a walk and someone asked if our smallest one was a gueanie pig ((however it's spelt))
I decided to create reboots of my games on RPG Maker MV. I'm happy.
So, as i finish setting up my items for part 1 of my game, I realized I forgot to finalize an ENTIRE category of items. Know which ones? The Fallen Feathers....BTW my game is called "Fallen Feather"

Made some new friends, and blew up a puzzle... Happens.
A new RPG Maker music pack is coming out soon! Below is a demo of one of the compositions in the pack, Heroic Battle. More details coming soon!