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

How do I make a brick that slowly kills? (Please help I've been waiting)

I wanted to make a brick so when you are on it, it slowly damages you as long as you are on it. For example, you're head is in a water brick and you are supposed to drown, right? So you slowly lose 5 health until you die as long as your head is underwater. How can I do this? This is my script and it seems to not work.



function onTouched(part)
	local h = part.Parent:findFirstChild("Humanoid")
	if h~=nil then
		for i = 1, 2000 do
			wait(1)
		h.Health = h.Health - 5
		end

		
	end
end

script.Parent.Touched:connect(onTouched)

1 answer

✓ Accepted answer
local debounce = false

script.Parent.Touched:connect(function (hit)
if not debounce then debounce = true
guy = hit.Parent:FindFirstChild("Humanoid")
if guy ~= nil then
--[[Next line is optional, it just makes the person unable to move.
guy.Torso.Anchored = true]]--
guy.Health = guy.Health - 0.003
wait(0.01)

debounce = true
end
end

I believe this would work hopefully

1 comment

0

This script does not seem to work, I tested it out and it only damages me once and stops. Is there supposed to be something that is missing?

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