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

How can I make this Explosion?

How do you make it so if something Explodes; there becomes a Sphere that basically appears at the explosion? I only know how to do the instance.new I cannot mannage to exactly make the two functions cooperate together.

1 answer

You don't need to make "two functions cooperate", you just write your code like you normally would. You probably are looking for something like this maybe?

function explode(pos) -- I'd make a function for it
	local sphere = Instance.new("Part")
	sphere.Shape = Enum.PartType.Ball
	sphere.CanCollide = false
	sphere.Anchored = true
	sphere.Size = Vector3.new(25, 25, 25)
	sphere.Transparency = .7
	sphere.BrickColor = BrickColor.Yellow()
	sphere.CFrame = CFrame.new(pos)
	local exp = Instance.new("Explosion")
	exp.Position = pos
	sphere.Parent = Workspace
	exp.Parent = sphere
	Game:GetService("Debris"):AddItem(sphere, 3)
end

-- Ex:
explode(Vector3.new(0, 0, 0))

Part.Touched:connect(function() -- A usage example
	explode(Part.Position)
end)

4 comments

0

I've upvoted you, but please change your script's line 14 to be 'game:GetService("Debris"):AddItem(sphere,3)'. It's a better solution.

0

And why is that a better solution?

0

Never question the Weaver. The last one to question 'It' has never been seen again.

0

I'll try my luck :p

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