Project 327: Exploder Course

5. Tell the script to find all your exploder parts

The reason we put this script inside of ServerScriptStorage is so that this singular script can act behind the scenes and find ALL of your exploder parts.

Starting point file for this challenge

Steps

1. Tell the game to find everything in the Workspace folder

In other words, tell the game to find all the children in the Workspace parent folder. 

game.workspace:GetChildren()

2. Keep track of the children

Label all the children as a variable called "children" 

children = game.workspace:GetChildren()

3. Create a forever loop

In Lua, this is made by typing "while true do." 

Then, hit return to create an end to the loop. 

while true do end

4. In the forever loop, create a for loop to cycle through the children

A for loop is used to cycle through a list. Create this inside the forever loop. 

We just made a list of everything in the Workspace folder, so we need to cycle through it. 

Hit return to create an end to this loop. 

for _, child in pairs(children) do end

5. Inside the for loop, check for any children named "Exploder"

In other words, find anything in the Workspace folder called "Exploder." 

if child.Name == "Exploder" then end

6. If there's a child named "Exploder" then tell it to explode

For now, we'll tell it to run a function called "Explode" with the parameter of "child" 

Roblox might give you an error, because we haven't actually made an "Explode" function yet! We will, soon! 

Explode(child)

7. Add a delay after the for loop, inside the forever loop

Without this 1 second delay, Roblox would be running this code at super speed and just crash the game. 

wait(1)

8. Lists in Roblox

This gif shows show tables work in Roblox.