Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I make a part explode?

Asked by 7 years ago
Edited 7 years ago
Explosion = Instance.new("explosion")
Explosion.position = script.parent.position

If I'm right, this should explode a part if I insert it into a part.

ps. I'm on my phone so I can't test this

2 answers

Log in to vote
3
Answered by 7 years ago
Edited 7 years ago

Problem:

You seem to have problems with the capitalization and parenting of this particular issue. Mostly it is just the capitalization. Also it is recommended to have your variables local.

Solution:

Just parent the Explosion into the parent at which you want the Explosion to occur and fix the capitalization where needed.

Code(Fixed):

local exp = Instance.new("Explosion") --Just abbreviated the variable and capitalized the Explosion so you can create the Instance of Explosion
exp.Parent = script.Parent --You can parent it there or Workspace. Whatever is more convenient to you. The part will be workspace anyway so. 
exp.Position = script.Parent.Position--Fixed capitalization issues here too.

If you need any more help as to why certain things are the case just comment and I would be happy to help. If it helped you don't forget to accept the answer.

0
what does this do "exp.Parent = script.Parent" SmugNyan 24 — 7y
0
exp is the set variable for the created explosion so the new explosion is put into ur script's parent User#18043 95 — 7y
0
ah i see SmugNyan 24 — 7y
Ad
Log in to vote
3
Answered by 7 years ago

Capitalization is important for Parent and Position. Otherwise, it is suspected as a non-existing variable.

Furthermore, you must set where your explosion resides in, also known as it's parent. In this case, you want it into the script's parent. So you put:

Explosion.Parent = script.Parent

The parent of the explosion must be set before setting it's position and that's how you create a explosion into the part you want.

Optionally, for better effect, you can destroy the part to create a realistic boom and poof with your part.

script.Parent:Destroy() -- you can also use :Remove() but that does the same

Answer this question