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

how to make damage resistance? (health)

Asked by
pwgth 11
3 years ago

Ok, instead of making you guys have a very hard time with an extremely difficult way of making damage resistance, I just want to know how to change the player's health&MaxHealth. Here's what I'm asking: say a player steps on an armor pad, the player has 20hp and a max health of 100 (the average) how do I make it so that for (insert random amount of time), they actually have 40 HP and max health of 200 HP. Then, if they take damage (say they're at 5 HP/200) their hp goes back to 2.5 HP out of 100.

so the script multiplies their health by 2 and after (insert the amount of time) the hp divides by 2 (back to normal)

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Here's how I would do it:

local armorPad = script.Parent --gets your armor pad (assuming the script is under it)
local armorOn = false --just a debounce

armorPad.Touched:Connect(function(hit)
    local humanoid = hit.Parent:FindFirstChild("Humanoid") --gets humanoid from hit (the one who that armorPad)

    if humanoid and not armorOn then --checks for humanoid and debounce
        armorOn = true --sets debounce to true

        humanoid.Health *= 2 --doubles health
        humanoid.MaxHealth *= 2 --doubles max health

        wait(10) --waits 10 seconds before v
        armorOn = false --setting debounce to false

        humanoid.Health /= 2 --halfs health
        humanoid.MaxHealth /= 2 --halfs max health
    end
end

Resources that may help: https://developer.roblox.com/en-us/articles/Debounce https://developer.roblox.com/en-us/api-reference/event/BasePart/Touched https://developer.roblox.com/en-us/api-reference/class/Humanoid

0
thanks for the assistance. pwgth 11 — 3y
0
though it seems that the script isn't working, reading the script, it truly seems that it should work. but it seems that when touching the pad, nothing happens. pwgth 11 — 3y
0
add an end) on line 19 JesseSong 3916 — 3y
Ad
Log in to vote
-1
Answered by
xxaxxaz 42
3 years ago

idk try this

stuff:Connect(function(player) -- replace stuff with the function that will get it to start
player.Health = player.Health * 2
player.MaxHealth = player.MaxHealth * 2

end)



Answer this question