My concept of a rocket bullet

The following code below is my concept of rocket bullet. I wanna ask how can I make it so that when it hits something, the adjoining parts of that hit part will be unanchored as well, the code is untested yet so tell me if it works and give me tips on how to make this rocket bullet effect better.

local rocketBullet = Instance.new(“Part”)
rocketBullet.Size = Vector3.new(0.5,0.5,2)
rocketBullet.Position = RocketHandle.CFrame.lookVector

local BV = Instance.new(“BodyVelocity”)
BV.Velocity = (Mouse.Hit.P - RocketHandle.Position).Unit

local explosion = Instance.new(“Explosion”)

BV.Parent = rocketBullet
rocketBullet.Parent = workspace

rocketBullet.Touched:Connect(function(hit)
    if hit:IsA(“Part”) or hit:IsA(“MeshPart”) or hit:IsA(“UnionOperation”) then
        explosion.Parent = rocketBullet
        hit.Anchored = false
        Debris:AddItem(rocketBullet,0.01)
    end
end)
1 Like

Right off the bat I can notice a thing that could be fixed.

if hit:IsA(“Part”) or hit:IsA(“MeshPart”) or hit:IsA(“UnionOperation”) then

Should be replaced with

if hit:IsA("BasePart")

To unanchor all parts in the model you would do something like this:

for i, v in pairs(modellocation) do
     spawn(function(
          v.Anchored = false
     end)
end

Hope this helps you out!

1 Like

So I can do like elseif statement for this?