Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I set the parent of Instance.new correctly?

I am trying to have a gun have a mini explosion by its hole when the gun is fired, everything else about this works fine but having the parent set. I can't seem to get it to set the parent as the part where I want the explosion to be. This is what I have so far

		FireFlash = Instance.new("Explosion")
		FireFlash.Visible = false
		FireFlash.BlastPressure = 0
		FireFlash.ExplosionType = Enum.ExplosionType.NoCraters
		FireFlash.DestroyJointRadiusPercent = 0
		FireFlash.Visible = true
		FireFlash.Parent = hole

1 comment

0

Pretty sure you did everything right...

1 answer

✓ Accepted answer

The parent of the explosion does not affect where the explosion ends up. If you want to change where the explosion ends up, you'll have to change the position property.

Here's an example:

FireFlash = Instance.new("Explosion")
FireFlash.Visible = false
FireFlash.BlastPressure = 0
FireFlash.ExplosionType = Enum.ExplosionType.NoCraters
FireFlash.DestroyJointRadiusPercent = 0
FireFlash.Visible = true
FireFlash.Parent = game.Workspace
FireFlash.Position = hole.Position -- Assuming that hole is a part

You can also do something like this:

explosion.Position = Vector3.new(0, 0, 0) -- Makes an explosion at the center of the world

1 comment

0

Thanks raccoonyz, your advice worked.

This discussion is preserved as it was. New answers, comments, and votes are closed.