Roblox Heist: Exploding Traps

Step 1
Create a threatening looking object named "Bomb", and a script named "Exploding Trap"
Step 2
Create a reference to the Player (the parent of this script)
Step 3
Give the script a function named "explode" and connect it to the Touched event for each piece of the player
Step 4
First we check if "collider" is named "Bomb"

Anything can Touch this player, but we only want it to explode if the Bomb touches it

Step 5
If the player touches the bomb, we'll destroy the bomb and set the player's health to 0
Check Your Work
Step 6
Your trap should now kill the player, but it won't create an Explosion yet..
Step 7
Next we'll make use of the built-in Explosion effect Roblox has given us

Using a function named Instantiate we can create these objects

Step 8
Instantiate a new "Explosion" and set it's Parent to the Workspace so it appears in our game

Notice we need to set the position of the explosion...

Check Your Work
Step 9
Now we create an explosion, but the player dies before the explosion can send them flying!
Step 10
Add a very brief wait in-between the explosion being created and the player dying
Check Your Work
Step 11
Now the explosion should send you flying!
Step 12
In the next lesson we'll be making a pair of sliding doors
Roblox Heist: Exploding Traps Info


MVCode Clubs

Created By

Newprofile jamie


Roblox Heist Game

Access Level


For Teachers and Schools

Teach coding to your students with MVCode Teach

MVCode offers an integrated product designed to teach coding to students.

Learn more about MVCode Teach