I made an explosion script, however my burger doesn’t explode. How do I make it Explode?
local explosion = Instance.new("Explosion")
explosion.Position = position
explosion.BlastRadius = radius
explosion.Parent = game.Workspace
explosion:Play()
end
script.Parent.Touched:Connect(function(BasePart)
if BasePart.Name == "Burger" then
createExplosion(Vector3.new(0, 5, 0), 5)
end
end)
Have you tried debugging it? Maybe its not the explosion itself causing the error but there is an error with your TouchedEvent. Add a print line to both the createExplosion function and the innerpart of your if request.
local function createExplosion(position: Vector3)
print("Function ran")
local explosion = Instance.new("Explosion")
explosion.Position = position
explosion.BlastRadius = radius
explosion.Parent = game.Workspace
explosion:Play()
end
script.Parent.Touched:Connect(function(BasePart)
if BasePart.Name == "Burger" then
print("if request passed")
createExplosion(Vector3.new(0, 5, 0), 5)
end
end)
Nevermind, I figured it out. I was exploding it nowhere near the part I wanted to explode it at.
local function createExplosion(position, radius)
local explosion = Instance.new("Explosion")
explosion.Position = position
explosion.BlastRadius = radius
explosion.ExplosionType = Enum.ExplosionType.NoCraters
explosion.Parent = game.Workspace
end
script.Parent.Touched:Connect(function(BasePart)
if BasePart.Name == "Burger" then
createExplosion(Vector3.new(-276.998, 3.339, -60.125), 5)
end
end)