I'm trying to make a script where if a car is going over 70 AND it hits a part (yes, it destroys all the models children) it will BreakJoints(). Except that doesn't happen. It worked fine without the velocity part. Anyone help?

function onTouched(hi)


local Speed = 70

    if script.Parent.Parent.Parent.VehicleSeat.Velocity.Magnitude >= Speed then
script.Parent:BreakJoints()
script.Parent.Parent:BreakJoints()



end end



connection = script.Parent.Touched:connect(onTouched)

7 comments

0

Have you tried checking how big is the velocity on impact? Also, how come the car is script.Parent.Parent but seat itself is that far back in ancestor list?

0

It's a special chassis, called SS3.57. The front, which can smash up, is grouped. There's body, wheels, etc.

0

Try putting print( script.Parent.Parent.Parent.Parent.VehicleSeat.Velocity.Magnitude ) for sake of debugging.

0

That is before the if line

0

I'll do that.

0

The number of speed does return into output on hit, but the joints don't break.

0

I got it working! Turns out that velocity is different to vehicleseat speed. Thank you, Zars!