How to increase health when part is touched

So hello again, I need help how do I increase a players health when they touch a part? I kewp searching how but cannot find anything, I am new to this so please do not judge me thank u :>

1 Like

Drop this into a script within the part.

local part = script.Parent

local debounce = false
local DEBOUNCE_TIME = 3 -- This is the cooldown period in between touches

local HEALTH_INCREASE = 25 -- Amount of health added each time a player touches

part.Touched:Connect(function(hit)
    if not debounce then
        local humanoid = hit.Parent:FindFirstChildOfClass("Humanoid")

        if humanoid then
            debounce = true
            humanoid.Health += HEALTH_INCREASE
            task.wait(DEBOUNCE_TIME)
            debounce = false
        end
    end
end)

Oh dude thank u, thanks for helping beginners like me, appreciate it!

1 Like