A kill brick is one of the most common hazards in Roblox games. When a player touches it, they take damage or are instantly removed. You'll need a Part, a script, and a basic understanding of the Touched event to make one.
Kill bricks are useful for creating challenge maps, obstacle courses, and danger zones. Let's build one from scratch.
Setting Up the Part
First, create a new Part that will be your kill brick:
- In Roblox Studio, click the Part button in the Home tab.
- Click in the workspace to place it.
- In the Properties panel, give it a name like
KillBrick. - Set its size and position where you want it (for example, a floor hazard).
- Optional: change its Color or Material to make it look like a hazard (red, spikes, lava texture, etc.).
Make sure CanCollide is enabled if you want players to walk on it, or disable it if you want them to fall through.
Writing the Script
Now add a Script to detect when players touch the brick:
- Select your KillBrick part in the workspace.
- In the Home tab, click Script (this inserts a Script inside the part).
- Delete the default code and replace it with the following:
local brick = script.Parent
brick.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
humanoid:TakeDamage(100)
end
end)This script does three things:
script.Parentrefers to the KillBrick itself.Touched:Connect()listens for when something touches the brick.hit.Parent:FindFirstChild("Humanoid")checks if the touching object is part of a character (only characters have a Humanoid).humanoid:TakeDamage(100)removes 100 health (usually instant death since players have 100 health by default).
Adding a Debounce
Right now, if a player stands on the brick, they'll take damage many times per second. A debounce prevents this by adding a cooldown:
local brick = script.Parent
local debounce = {}
brick.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid and not debounce[hit.Parent] then
debounce[hit.Parent] = true
humanoid:TakeDamage(100)
wait(0.5) -- Cooldown duration
debounce[hit.Parent] = nil
end
end)The debounce table keeps track of which players have recently touched the brick. If they're already in the table, they won't take damage again until the cooldown expires.
Instant Kill Alternative
If you want to instantly remove the player instead of dealing damage, use this version:
local brick = script.Parent
local debounce = {}
brick.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid and not debounce[hit.Parent] then
debounce[hit.Parent] = true
hit.Parent:FindFirstChild("Head"):Destroy()
end
end)Destroying the Head part causes the entire character to break apart and vanish. This is faster than dealing damage and works for instant-kill zones.
Customizing Your Kill Brick
Change damage amount: Replace 100 with any number. For example, humanoid:TakeDamage(25) deals only 25 damage, letting players survive if they have armor or buffs.
Add a sound: Insert a Sound into your KillBrick, then play it when the brick is touched:
local brick = script.Parent
local sound = brick:WaitForChild("Sound")
brick.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
humanoid:TakeDamage(100)
sound:Play()
end
end)Make it only affect players, not NPCs: The Humanoid check already does this. Only character models have Humanoids.
Add a visual effect: Create particles or colors that change when someone touches it. This requires inserting a ParticleEmitter or using Instance.new() in your script.
Common Mistakes
Script is in ServerScriptService instead of the brick: Put the script directly inside the KillBrick Part. If it's in ServerScriptService, use a RemoteEvent to communicate between the script and the brick.
The brick doesn't work at all: Make sure CanCollide is true (or false, depending on your design) and that the brick is in the workspace, not hidden in ReplicatedStorage.
Damage fires too many times: Add a debounce as shown above. Without it, Touched fires continuously while contact is active.
Script errors mention "Humanoid is nil": This means the script is finding non-character objects. The if humanoid then check prevents crashes, but make sure you're only placing the brick where players will touch it.
Next Steps
Once you've mastered the basic kill brick, try:
- Creating multiple kill bricks with different properties (spike traps, fire, acid, etc.).
- Adding a respawn system so players come back instead of staying dead.
- Building a full obstacle course with platforms and hazards.
- Using Region3 or Raycasting for non-touch-based damage zones.