Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to Make a vehicle part crash system?

Asked by 2 years 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
2 years 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