So I've made a cannon that shoots fireworks on the press of a button. It works except the fireworks won't get removed. Here's the entire script I wrote out(Lot's of copying and pasting LOL):
firework = game.ServerStorage.Firework
barrel = script.Parent.Barrel
buttonHit = false
script.Parent.Button.Touched:connect(function(hit)
if not buttonHit then
buttonHit = true
local fireworkCopy = firework:Clone()
fireworkCopy.Parent = game.Workspace
fireworkCopy.Position = barrel.Position
fireworkCopy.Velocity = Vector3.new(0,350,0)
wait(2)
fireworkCopy.Anchored = true
fireworkCopy.F1.Enabled = true
fireworkCopy.P1.Enabled = true
fireworkCopy.P1.LightEmission = math.random(0.5,1)
fireworkCopy.P1.Acceleration = math.random(1,10),-5,math.random(1,10)
fireworkCopy.P2.Enabled = true
fireworkCopy.P2.LightEmission = math.random(0.5,1)
fireworkCopy.P2.Acceleration = math.random(1,10),-5,math.random(1,10)
fireworkCopy.P3.Enabled = true
fireworkCopy.P3.LightEmission = math.random(0.5,1)
fireworkCopy.P3.Acceleration = math.random(1,10),-5,math.random(1,10)
fireworkCopy.P4.Enabled = true
fireworkCopy.P4.LightEmission = math.random(0.5,1)
fireworkCopy.P4.Acceleration = math.random(1,10),-5,math.random(1,10)
wait(10)
fireworkCopy:Destroy() -- This is the code that doesn't run.
buttonHit = false
end
end)
For some reason, there's no error that shows up in the output. Anyone know why this happens?
