Ad
Log in to vote
0

How to Make a vehicle part crash system?

Asked by 1 month ago

i want the part to brake or fall apart when crashed into with a car

1 answer

Log in to vote
0
Answered by
jundell 106
1 month ago

Connect the BasePart.Touched event to BasePart:BreakJoints(), and make sure the part that touches the car is not part of the car.

This script should be put in your car. Any part named Wheel will not fall off.

local car = script.Parent
for _ , part in pairs(car:GetDescendants()) do
    if part:IsA(“BasePart”) and part.Name ~= “Wheel” then
        part.Touched:Connect(function(hit)
            if not hit:IsDescendantOf(car) then
                part:BreakJoints()
            end
        end)
    end
end
Ad

Answer this question