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

How do I make this script only deduct a quarter of their health each time they touch it?

Asked by 6 years ago

I would like to know how to tweak this script so it deducts 25 health instead of deducting 100 health each time some one touches it?

function onTouch(part) local human = part.Parent:findFirstChild("Humanoid") if (human == nil) then return end human.Health = 0 end script.Parent.Touched:connect(onTouch)

1 answer

Log in to vote
0
Answered by
522049 152
6 years ago
debounce = false
function onTouch(part) 
    local human = part.Parent:FindFirstChild("Humanoid")
    if not human then
        human = part.Parent.Parent:FindFirstChild("Humanoid")
    end
    if debounce == false and human then
        debounce = true
        human:TakeDamage(25)
        wait(1)
        debounce = false
    end
end
script.Parent.Touched:connect(onTouch)
Ad

Answer this question