Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

2 answers

✓ Accepted answer

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)

2 comments

0

Thank you! This helped me a lot.

0

np

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.