Roblox Heist: Exploding Traps

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

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
Temp1557015224
Check Your Work
Step 6
Your trap should now kill the player, but it won't create an Explosion yet..
Planning
Step 7
Next we'll make use of the built-in Explosion effect Roblox has given us
Temp1532050865

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
Temp1557015318

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
Temp1557015393
Check Your Work
Step 11
Now the explosion should send you flying!
Planning
Step 12
In the next lesson we'll be making a pair of sliding doors
Roblox Heist: Exploding Traps Info

Account

MVCode Clubs

Created By

Newprofile jamie

Course:

Roblox Heist Game

Access Level

premium

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