Project 327: Exploder Course

7. Create an explode function

Create a function called "Explode" with a single parameter for the exploding part itself. This function should create a new instance of the explosion, make sure the explosion is in the Workspace, and finally make the explosion happen at the same position as the exploder part.

Starting point file for this challenge

Steps

1. Create a function called "Explode"

Tell the computer your're starting a new function by just typing "function."

This function can go after you create the explosion instance, but before the forever loop. 

Next, write the name of your new function, which we'll call "Explode." 

function Explode

2. Create a parameter called "part" for your function

A parameter helps functions be a little more specific. In this case, we'll have a function called "part" and "part" will keep track of what is actually exploding. 

function Explode(part)

3. Hit return to create an "end" to your function

Anything written between the word "function" and "end" will the instructions to explode your brick. 

function Explode(part) end

4. Create a new instance of "Explosion" in the function

Copy and paste the same line of code you wrote earlier that created a new Instance of an "Explosion" 

Remember to label the instance "explosion." 

explosion = Instance.new("Explosion")

5. Make the workspace the parent of the explosion

Copy and paste the same line of code you wrote earlier that sets the explosion's parent equal to the workspace. 

Remember, this makes sure the explosion actually shows up inside your game! 

explosion.Parent = game.workspace

6. Set the explosion's position equal to the part's position

It'd be really weird if the brick made an explosion happen randomly hundreds of feet away. Set the explosion's position equal to the part's position. 

explosion.Position = part.Position