How to get the force of a grouped part?

I’m trying to get the force of a part to see how powerfully it has hit another part, for example a car crashing into a wall. I’m trying to make crash physics but I have come across a bug?

Here’s my code I’m using:

local function onCollision(otherPart)
    local impactThreshold = 1000 

    local velocity = Part.Velocity
    local mass = Part:GetMass()
    local impactForce = mass * velocity.Magnitude

    if impactForce >= impactThreshold then
        -- break welds
    end
end)

Part.Touched:Connect(onCollision)

For some reason this doesn’t work on grouped parts, I’m not sure why?

Any help appreciated!

Anyone know what I mean? Let me know if I should be more clear.

Not entirely sure what you mean by grouped parts in this context, but I’ll provide some assistance anyway:

Your code only triggers when a part is directly touched by some object that wasn’t touching it before. Multiple parts in a car would all be touching even other constantly, however wouldn’t actually touch the object it collided with, meaning the code doesn’t fire.

Does my explanation makes sense in relation to the issue you are facing, or have I misinterpreted it? LMK and I can try to provide either an alternative explanation as to what happened, or I can try to provide a solution.

My code works when its a single ungrouped part, for some reason when I group the part with another part it doesn’t work.

The function would only fire on hit if the impact force is greater than the threshold so that shouldn’t be the issue.

Grouped parts that are welded rogether are known as an assembly.

You can use the newer properties such as part.AssemblyMass and part.AssemblyLinearVelocity to get the summed total of the velocities.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.