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

How do you make a slow kill brick?

So basically I am trying to make a brick that slowly reduces your health but if you are not touching it anymore, you stop losing health. This is my attempt but it doesnt work.

function damageplr(hit)
	wait(1.5)
	if hit.Parent.Head then
		hit.Parent:FindFirstChild("Humanoid").Health = hit.Parent:FindFirstChild("Humanoid").Health - 5 
	end
end

function TouchEnd(hit)
	
end

script.Parent.Touched:connect(function(hit)
	wait()
	repeat damageplr() until TouchEnd()
	hit.Anchored = false
end)

script.Parent.TouchEnded:connect(TouchEnd)
script.Parent.Touched:connect(damageplr)

1 comment

0

you went all out like you overcooked da chicken

4 answers

✓ Accepted answer

This could do the job, dont know if it works I dont have time to test it, But worth a try =)

script.Parent.Touched:connect(function(hit)
    pcall(function()
        hit.Parent.Humanoid:TakeDamage(5)
    end)
end)

4 comments

0

One problem, it damages me only a little and it doesnt slowly kill me, rather damages me and stops even when I'm still on the brick.

0

If you want more damage, Higher the 5. And you can not 'slowly kill' you can only damage and once the humanoid health value reaches 0 you're considered dead. As for the fact it stops when you're on the block, a 'while true do' statement or 'repeat' may do the trick

0

thx I got it now

0

Make sure to accept my answer if it helped :)

Here is an answer

works as of july 7 2018

wait(1)
function onTouched(part) 
local h = part.Parent:findFirstChild("Humanoid") 
if h~=nil then 
h.Health = h.Health -1  --Change that number to the ammount of Health you want to decrease
end 
end 

script.Parent.Touched:connect(onTouched)

now i know this was already answered but that didnt work for me and i made one without the pcall

function OnTouch(hit)
hit.Parent.Humanoid:TakeDamage(5)
    end
script.Parent.Touched:Connect(OnTouch)(hit)
	

it works for me and i hope this works for you

Yes,actually you can just keep doing (hit.Parent.Humanoid.TakeDamage(5), do it 20 times cause 5 * 20 is 100 and thats all the health a player on roblox has hope this helps

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