Kahibaro
Discord Login Register

3.1.2 Kill bricks

Why Kill Bricks Matter in an Obby

Kill bricks are one of the core elements that make an obby feel challenging and exciting. A kill brick is any part that causes the player to die or reset when they touch it. You might use bright red lava floors, spinning blades, neon lasers, or falling rocks. All of these are just Parts with a script that changes the player’s health or moves them back to a checkpoint.

In an obby, kill bricks create tension. Players must time their jumps, watch their movement, and pay attention to the environment. Used carefully, they reward skill without feeling unfair.

Creating a Basic Kill Brick Part

To begin, create a simple kill brick. Insert a normal Part into the Workspace, resize it into a platform or a floor, and move it into place where players will try to avoid it. Give it a clear color that says danger such as bright red, and optionally turn on Material to something like Neon so it stands out from safe platforms.

Name the part something that is easy to recognize, for example KillBrick. A clear name makes it easier to find and reuse later when your game becomes more complex.

If you want the kill brick to stay in place and not fall due to physics, make sure Anchored is checked in the Properties window. For a basic kill brick, you usually want it anchored so players can predict where it is.

Detecting When a Player Touches a Kill Brick

A kill brick has to know when a player touches it. Roblox parts can detect touch using the Touched event. You connect a function to this event, and Roblox runs that function whenever something makes contact with the part.

Inside the Script, your code will receive one argument, often named otherPart, which is the part that touched your kill brick. From there, you need to find out if that part belongs to a character and then change that character’s health.

Here is a simple script that you can place inside the kill brick:

local killBrick = script.Parent
local DAMAGE = 100
local function onTouched(otherPart)
    local character = otherPart.Parent
    if not character then
        return
    end
    local humanoid = character:FindFirstChild("Humanoid")
    if humanoid then
        humanoid.Health = humanoid.Health - DAMAGE
    end
end
killBrick.Touched:Connect(onTouched)

This script does three important things. It listens for touches on the part. It checks if the touching part has a Humanoid in its parent, which means it is a character. It subtracts health from that humanoid so the player takes damage or dies.

Important rule: Always check that the touching object belongs to a character with a Humanoid before changing health, or your script may affect unwanted objects or cause errors.

Instant Death vs Damage Over Time

You can turn a kill brick into instant death by setting the health directly to zero instead of subtracting damage. This is useful for lava pits, lasers, or bottomless drops where you want the player to die as soon as they touch it.

For example:

local killBrick = script.Parent
local function onTouched(otherPart)
    local character = otherPart.Parent
    if not character then
        return
    end
    local humanoid = character:FindFirstChild("Humanoid")
    if humanoid then
        humanoid.Health = 0
    end
end
killBrick.Touched:Connect(onTouched)

You can also design kill bricks that hurt the player gradually. Instead of one big hit, you can apply a small amount of damage every time the brick is touched, or at intervals while the player stays on it. A slow acid floor or a toxic gas area might use smaller damage values like 5 or 10 per touch.

A simple way for delayed damage is to give a smaller DAMAGE value and possibly add a short cooldown so standing on the brick does not trigger hundreds of hits at once. A basic cooldown uses a canDamage flag:

local killBrick = script.Parent
local DAMAGE = 10
local COOLDOWN = 0.5
local canDamage = true
local function onTouched(otherPart)
    if not canDamage then
        return
    end
    local character = otherPart.Parent
    if not character then
        return
    end
    local humanoid = character:FindFirstChild("Humanoid")
    if humanoid then
        canDamage = false
        humanoid.Health = humanoid.Health - DAMAGE
        task.delay(COOLDOWN, function()
            canDamage = true
        end)
    end
end
killBrick.Touched:Connect(onTouched)

Visual and Audio Feedback

Kill bricks feel better and clearer to players when they have strong visual and audio feedback. If you use bright colors and distinct materials, players can learn that a certain look always means danger. For example, all red neon parts are deadly, while gray concrete is safe.

You can also add particle effects or sounds when the brick is touched. To do this, insert a Sound or ParticleEmitter into the kill brick, and inside your onTouched function, play the sound or enable particles when the player hits it.

For example, to play a sound when the brick is touched:

local killBrick = script.Parent
local hitSound = killBrick:FindFirstChild("HitSound")
local function onTouched(otherPart)
    local character = otherPart.Parent
    if not character then
        return
    end
    local humanoid = character:FindFirstChild("Humanoid")
    if humanoid then
        humanoid.Health = 0
        if hitSound then
            hitSound:Play()
        end
    end
end
killBrick.Touched:Connect(onTouched)

This makes deaths feel more dramatic and gives players clear feedback about what went wrong.

Making Moving and Rotating Kill Bricks

To make your obby more interesting, you can turn kill bricks into moving or rotating hazards. A spinning bar or a sliding laser wall forces players to time their jumps more carefully than static obstacles.

The simplest way to add movement is to use Roblox constraints or to animate the part with a script that updates its position or rotation over time. For a rotating kill brick, you can adjust the Orientation of the part every frame.

Here is a basic example that rotates the kill brick:

local killBrick = script.Parent
local ROTATION_SPEED = 90
game:GetService("RunService").Heartbeat:Connect(function(deltaTime)
    local currentOrientation = killBrick.Orientation
    local newY = currentOrientation.Y + ROTATION_SPEED * deltaTime
    killBrick.Orientation = Vector3.new(currentOrientation.X, newY, currentOrientation.Z)
end)

You can combine this rotation script with the touch script from earlier to make a spinning bar that kills players if they are hit.

For sliding kill bricks, you can move between two positions. For instance, you might save a start and end position as Vector3 values and interpolate between them over time to create a back and forth motion.

Common Problems and How To Avoid Them

When working with kill bricks, some issues appear again and again. One common problem is the brick killing non player objects, for example loose parts or tools that fall into it. To reduce this, you can check more carefully that the character actually belongs to a player. You can do this by searching for a HumanoidRootPart or looking for a Player in the Players service that matches the character model.

Another issue is repeated damage. If the brick kills a player several times in a row as they respawn, this can feel unfair. Make sure your kill brick is not touching the spawn point. You can also use short cooldowns like in the earlier example to prevent massive damage spam.

Finally, scripts should be easy to copy and reuse. Instead of writing a new script for every kill brick, consider creating one Script and pasting it into each brick that should be deadly. Use variables like DAMAGE and COOLDOWN so you can adjust behavior quickly without changing the whole script.

Designing Fair and Fun Kill Brick Challenges

Kill bricks should challenge the player, not frustrate them. Give players a chance to see the danger before it kills them. Avoid placing kill bricks where the camera cannot see. Make sure jumps are possible and that there is a small margin for error.

You can start with simple flat kill floors that teach players the basic rule touch red and you die. Later, introduce moving hazards, narrow platforms with kill bricks on the sides, or patterns that require timing. Each new type of kill brick should build on what the player already understands.

When you test your obby, try to complete it yourself without shortcuts. If you fail repeatedly on the same kill brick, consider making it a bit wider, slower, or less punishing. Kill bricks are powerful, so good level design and clear visuals are just as important as the script that makes them deadly.

Views: 25

Comments

Please login to add a comment.

Don't have an account? Register now!