Scripting Lesson 008: Inserting Instances

What is an instance? An instance in roblox terms is basically something that is in the game, whether its a brick, script, light, or even an explosion. In many examples in this lesson, I will teach all of you how to insert a few items such as these. First let's take a look at Castaway of all things (Imagination Tech's Roblox Machinima series). Here is a script I used in Episode 2 and soon Episode 3. It is a script that causes an explosion.

Now the green text in the script pretty much explains it, but we also can see plenty of properties being changed like BlastPressure, Position, etc. Instance.new("NameOfInstance") Is all that's new here, but let's take things up a notch. Let's see what happens when we are in the game testing.

You can see that line 8 sets the Parent as workspace, but won't those explosions fill up in the workspace and lag everything? Well...not really. See, what happens is that explosions are unique because they automatically clear out after they are done...well...exploding. Parts and other instances don't act this way. So here is a script showing how to get rid of a brick.

Now you can see that line 9 says Brick:Destroy() . This is how we can destroy or remove an instance from the game so the instances don't pile up. It all depends on what you want the script to do though.

Now you may notice the way I set a position to the part. Vector3 is another CFraming tool that I decided to save until now. It can be used for size, rotation, and position.

Well there you have it, a basic tutorial on how to insert an object. Remember to do as many properties that match your instance as possible to get just the right thing you want.

-Domswolf