I would use an Anonymous Function to do this.
Alright so we start by using an anonymous function and declaring what fire is.
1 | script.Parent.Touched:connect( function (hit) |
2 | local f = script.Parent:findFirstChild( "Fire" ) |
Now, we use the .Touched event in order to signal that IF the object the script is inside is either touched or is touching another object it will do something.
we also declare that f is fire because, we do not need to create the fire within the script it could later on cause complications.
Now lets move on to what happens WHEN this object is touched or touches something.
01 | script.Parent.Touched:connect( function (hit) |
02 | local f = script.Parent:findFirstChild( "Fire" ) |
04 | if hit.Parent:IsA( "Part" ) then |
06 | if hit.Parent.Name = = string.lower( "spreadable" ) then |
Now you might ask Why are we using an :IsA in the script, well this just checks if the object it touched is a Part, we also made a new variable called x that is now a Clone of Fire,
we also checked to see if the thing that hit or was hit by the objects name was "Spreadable"
string.lower is just fancy terms so that the name could be like this "SPreADabLE"
now lets make something happen AFTER it checks if it is a part and if the name is spreadable
01 | script.Parent.Touched:connect( function (hit) |
02 | local f = script.Parent:findFirstChild( "Fire" ) |
04 | if hit.Parent:IsA( "Part" ) then |
06 | if hit.Parent.Name = = string.lower( "spreadable" ) then |
now we made the variable x's parent hit.Parent which means the new parent of the cloned fire is what touched the brick
That is a simple way of making it spread from one brick to another.