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

How come my script won't create an explosion?

I've created a script that I thought should create an explosion inside the tool, but it won't work.

local function explosionTool()
	print("Explode?")
	local toolExplosion = Instance.new("Explosion")
	toolExplosion.Parent = script.Parent
end

script.Parent.Parent.Activated:connect(explosionTool)

The script is inside the Handle of the tool, but all it will do is the "print" part of the function. Why won't the rest of the function work?

1 comment

1

Explosions by default explode at the origin and not at the center of their parent. You need to set its position.

1 answer

Explosions won't position themselves to their parent automatically, you must do that part yourself by setting the explosion's Position property:

local function explosion()
	local blast = Instance.new("Explosion", script.Parent)
	blast.Position = handle.Position -- Make sure 'handle' is a BasePart.
end

tool.Activated:Connect(explosion) 

Make sure you replace all the variables with the objects you're working with.

1 comment

0

It did work, thanks.

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