Kill Bricks

How to make bricks that kill.

by megabean99

Author Avatar

To begin creating a killbrick, you will need a part with a script. The part should be named "killbrick," or something like that. Make sure that the part is parent of the script, so drag the script inside the part. Next, we will need to begin the script with a function.

function ontouch(part)

end

inside the function, we will need to find if a humanoid (stats of a player) is touching it. To do this, we will need to detect if the humanoid is there.

function ontouch(part)
local hum = part.Parent:FindFirstChild("Humanoid")
end

next, we will need to see if the humanoid is there, and not not touching the part. We can do this with this code.

function ontouch(part)
local hum = part.Parent:FindFirstChild("Humanoid")
if hum ~= nil then
end
end

Finally, we need to add the part that edits the humanoid's health, and in this case we will set it to zero.

function ontouch(part)
local hum = part.Parent:FindFirstChild("Humanoid")
if hum ~= nil then
hum.Health = 0
end
end
script.Parent.Touched:Connect(function(ontouch))

That last part was to run the function every time when the player steps on the part.

View in-game to comment, award, and more!