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

How to make a block that slowly kills you after touching it?

Asked by 3 years ago

Does anyone know how you can make a block that slowly kills you after being touched?

2 answers

Log in to vote
0
Answered by 3 years ago

Put this under the part that will kill

local killPart = script.Parent
local damage = 10 -- change this to how much damage to do

local debounce = true

killPart.Touched:Connect(function(part)
    if part.Parent:FindFirstChild("Humanoid") then
        debounce = false

        local hum = part.Parent:FindFirstChild("Humanoid") 

        hum:TakeDamage(damage)

        repeat wait() 
            killPart.TouchEnded:Connect(function()
                debounce = true
            end)
        until debounce
    end
end)
0
Thank you! This helped me a lot. Jake821181 2 — 3y
0
np ProjectInfiniti 192 — 3y
Ad
Log in to vote
0
Answered by
Subsz 366 Moderation Voter
3 years ago

You could make use of the Touched event and then slowly damage the player after he hits it.

Eg :

local globalDeb = false

part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') and not globalDeb then
globalDeb = true
repeat wait(0.8) hit.Parent.Humanoid:TakeDamage(10) until hit.Parent.Humanoid.Health <= 0
end
end)

Answer this question