Lesson 2
A kill brick
Goal: Reset a player who touches a part.
about 6 min3 practice exercises
A kill brick is a part that resets any player who touches it. Lava, spikes, lasers: they are all this script.
Add a part, make it bright red, name it Lava, and put a Script inside it:
local lava = script.Parent
lava.Touched:Connect(function(otherPart)
local character = otherPart.Parent
local humanoid = character:FindFirstChild("Humanoid")
if humanoid then
humanoid.Health = 0
end
end)
How it works:
Touchedfires when anything touches the lava and passes in the part that did, such as a foot.- That part's
Parentis the character model. - Every character has a Humanoid, the object that holds health and movement.
FindFirstChildreturns it, ornilif the thing that touched the lava was not a character. - Setting
Healthto 0 resets the player.
The if humanoid then check is what stops the script erroring when a loose part falls into the lava.
To make more kill bricks, duplicate the whole part (Ctrl + D). The script comes with it.
Try it in Studio
Optional, and the best way to make it stick.
Add the Lava part and script under your jumps. Fall in on purpose.
Go deeper on Rodex
Sources
Checked against Roblox's documentation on . The lesson is in our own words; these pages are the source of truth.