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

How do you make a slow kill brick?

Asked by 9 years ago

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)
0
you went all out like you overcooked da chicken Vortex_Vasne 89 — 4y

4 answers

Log in to vote
1
Answered by
Uroxus 350 Moderation Voter
9 years ago

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)

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. laughablehaha 494 — 9y
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 Uroxus 350 — 9y
0
thx I got it now laughablehaha 494 — 9y
0
Make sure to accept my answer if it helped :) Uroxus 350 — 9y
Ad
Log in to vote
0
Answered by 5 years ago

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)
Log in to vote
0
Answered by 4 years ago

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

Log in to vote
-2
Answered by 9 years ago

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

Answer this question