Help with kill script

How do I make a kill Brick script work properly

So I have a brick where you step on it you die but if you consistently jump on the kill break you wont die and you can just pass stages of the obby my just jumping straight thought kill bricks.

Script : script.Parent.Touched:Connect(function(hit)
local h = hit.Parent:FindFirstChild(“Humanoid”)
if h ~= nil then

h.Health = 0 – If you want to change this into speed do WalkSpeed = [number here]

end
end)

3 Likes

Can you please paste the script? That would be helpful.

1 Like

script.Parent.Touched:Connect(function(hit)
local h = hit.Parent:FindFirstChild(“Humanoid”)
if h ~= nil then

h.Health = 0
end
end)

1 Like

I believe if you set the part’s can-collide to false, then the touch event will fire more easily.

5 Likes

You’ll have to tell the brick to find something named “Humanoid” once it had been touched. Make sure you do this inside a touched event:

local humanoid = hit.Parent:FindFirstChild(“Humanoid”)

if humanoid then

    • take away health (make sure you use humanoid:TakeDamage(MaxHealth)

i did this on mobile

I did try that the only way to make it work is if I make like 4 bricks in each other that kill

You can do something like this:

script.Parent.Touched:Connect(function(hit)
local h = hit.Parent:FindFirstChild("Humanoid")
if h then
h:TakeDamage(9999) --Should kill it
end
end)

Remove the “~= nil” since you can just ask the script if they find the humanoid, just take away the health

1 Like

I’m trying that right now I’ll edit and see if it works

I think making it can’t collide works much better as far as I have tested it, you can’t jump on it anymore without dying.

I just have another question is there any way to make the brick work like 4 times for example if I make like 6 bricks overlapping in each other and make it can-colide it work but not with 1 part what is the problem

Some times it glitch’s out tho

Am I allowed to put a video in Roblox studio to send it on the dev fourm

local damage = 100 -- If you want the player dead, keep at 100. 
script.Parent.Touched:Connect(function(char)
   if char:FindFirstChildOfClass("Humanoid") then
      char.Humanoid:TakeDamage(damage)
   end
end)

Try that and let me know if it works. Put this script inside of the part.

1 Like

Setting the part to CanCollide off will enable it to kill instantly.

1 Like

Setting the part’s CanCollide doesn’t affect the damage. All that does is determines weather or not the player can go through the part or not.

1 Like

It allows the Touched event to fire easily even if the player keeps on jumping on the Part.

So is there any better method of killing a player with a kill script.

1 Like

You’re using the right method, but not in the correct way.

You want one part which is the brick. Cancollide should be true, and it should not be transparent.

The other part will be the hitbox. It is transparent and cancollide is false. It encompasses whatever area you want the player to die in. That is where the script should go.

1 Like

local killPart = script.Parent

local function kill(bodyPart)
local humanoid = bodyPart.Parent:FindFirstChild(“Humanoid”)
if humanoid then
humanoid.Health = 0
end
end

killPart.Touched:Connect(kill)