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

Is there an opposite technique of humanoid:TakeDamage()?

Asked by 5 years ago

Hello, iv heard about humanoid:TakeDamage(), but is there something like humanoid:AddHealth? I know i can still do humanoid.health = humanoid.Health + number, but its the same for takedamage, but takedamage() is faster to write, is can i do the same with adding health?

0
IM ON, ok so its easy, make it a negative number, for example, humanoid:TakeDamage(-1) will add 1 health. its just math, take away a negative number is like adding. idunnobut 27 — 5y
0
TakeDamage can take in negative numbers theking48989987 2147 — 5y

2 answers

Log in to vote
1
Answered by 5 years ago

Like @theking48989987 said, TakeDamage() takes any number, positive or negative. If the number given is negative, the Humanoid will be healed by that amount of Health:

local hum = game.Players.LocalPlayer.Character.Humanoid
hum:TakeDamage(-10) -- Heals 10 HP

However, TakeDamage() is unique about this. There is a bug that enables you to surpass the MaxHealth of the Humanoid using TakeDamage():

hum:TakeDamage(-100) -- If the Humanoid already has 100 HP, they'll surpass their 100 HP limit and they will have 200 HP

By what I know, this bug hasn't been fixed but it is indeed a unique bug.

0
Because of the weird bug you described, I would recommend to just increment the Health field value by whatever amount you desire. For example, `Humanoid.Health = Humanoid.Health + 1`. I wouldn't use TakeDamage for this. ScriptGuider 5640 — 5y
0
yeah that's how you prevent it from happening, I know DeceptiveCaster 3761 — 5y
Ad
Log in to vote
0
Answered by
gloveshun 119
5 years ago

yes, it works like humanoid:AddHealth() ex:

game.Players.LocalPlayer.Character.Humanoid:TakeDamage(60)

then the humanoid has health 40

Answer this question