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

How do I make the explosion instance not create until it's Parent is made?

So, I have a script where, when I step on a brick, the limbs of "Human" catch fire. After 3 seconds, I want an explosion to occur in the the Human's Torso. The problem is, the explosion is created in the Baseplate and doesn't parent to Torso after I clone it. All help is appreciated! Here's the script:

local part = script.Parent
local db = false

function explode(hit)
	local human = hit.Parent
	local explosion = Instance.new("Explosion")
	local fire = Instance.new("Fire")
	local myArray = {"Left Leg","Right Leg","Left Arm","Right Arm"}
	if human then
		if not db then
			
			db = true
			
			for i,v in pairs(myArray) do
				fire:Clone().Parent = human[v]
			end
			wait(3)
			explosion:Clone().Parent = human
			
			db = false
				    
				end
			end
		end
	

part.Touched:connect(explode)

Also, output isn't giving any errors.

2 comments

2

You do know that this code will error if the player has an arm or leg missing.

2

This code will also be ran for all touched parts with a parent as you do not check for a player / humanoid.

1 answer

You are creating the explosion too early. Create the explosion right before you are going to use it. Also it should be Human.Torso

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