Car Crash mechanic fixing

So, I have a part, and when something touches it, it breaks joints in that model, this works as a car crash mechanic for cars, but i was wondering if there was a way to stop it from breaking joints of specific parts of a character such as the Neck joint and the Torso, Humanoid root part etc.

if not joint.Parent.Parent:FindFirstChild([[Humanoid]]) then
    joint:Destroy()
end 

Is a good way to check if the joint is in a person. You could also do this for specific joints:

local AllowedJoints = {[[Neck]], [[UpperTorso]]}

if table.find(joint.Part0.Name) ~= false then
    -- Don’t destroy
elseif table.find(joint.Part1.Name) ~= false then
    -- Don’t destroy
else
    joint:Destroy()
end

if not joint.Parent.Parent:FindFirstChild([[Humanoid]]) then

function onTouched(hit)

hit:BreakJoints()

end

end

Here is the code im currently using inside of the Wall. its not working.

Try this

function hit(part)
    if not part.Parent:FindFirstChild([[Humanoid]]) then
        part:BreakJoints()
    end
end

script.Parent.Touched:Connect(hit)

Unfortunately, it doesn’t work, I tried editing it around a bit using the original script (That works perfectly except for how it still breaks the joints for the humanoid)

image it also seems that it doesnt recognize “part”

Can u send a screenshot of the entire function pls?

Replace part with hit
30 chars

thank you so much that works! :smiley:

1 Like