I am making a game and I have a rocket model that fly’s into another model but I also have a button that respawns the rocket and the cannon but I keep getting this error when pressing it twice here are the script:
(Script 1)
local rocket = game.ReplicatedStorage.Rocket
local button = game.Workspace.VipButtonRocket
local cannonC = game.ReplicatedStorage.RocketShooter:Clone()
local happyhome = game.ReplicatedStorage.HappyHome:Clone()
local house = game.Workspace.HappyHome
local canBoom = true
local function boom(otherPart)
wait(6)
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChildWhichIsA('Humanoid')
if humanoid and canBoom then
canBoom = false
for num, child in pairs(house:GetChildren()) do
if child:IsA('Part') then
local explosion = Instance.new('Explosion')
explosion.Parent = game.Workspace
child.Anchored = false
explosion.Position = child.Position
end
end
wait(3)
canBoom = true
end
end
button.Touched:Connect(boom)
wait(24)
happyhome.Parent = game.Workspace
happyhome:MoveTo(Vector3.new(1176, 51.4, 46))
cannonC.Parent = game.Workspace
cannonC:MoveTo(Vector3.new(1180, 39.5, 327))
game.Workspace:WaitForChild("RocketShooter"):Destroy()
game.Workspace.HappyHome:Destroy()
button.Parent = game.Workspace
button.Transparency = 0
(Script 2)
local rocket = game.ReplicatedStorage.Rocket
local button = game.Workspace.VipButtonRocket
local cannon = game.ReplicatedStorage.RocketShooter
local RCopy = rocket:Clone()
local CCopy = cannon:Clone()
local happyhome = game.ReplicatedStorage.HappyHome:Clone()
button.Touched:Connect(function()
RCopy.Anchored = true
button.Transparency = 1
button.CanCollide = false
button.Parent = game.Lighting
CCopy.Parent = game.Workspace
RCopy.Parent = game.Workspace
wait(5.5)
end)
while wait(.001) do
RCopy.CFrame = RCopy.CFrame + Vector3.new(0, 0, -1)
if RCopy.Position.Z < 96 then
RCopy:Destroy()
CCopy:Destroy()
end
end
Thanks.