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

Help! my velocity script won't work?

Asked by
cc0de 35
8 years ago

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)
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? ZarsBranchkin 885 — 8y
0
It's a special chassis, called SS3.57. The front, which can smash up, is grouped. There's body, wheels, etc. cc0de 35 — 8y
0
Try putting print( script.Parent.Parent.Parent.Parent.VehicleSeat.Velocity.Magnitude ) for sake of debugging. ZarsBranchkin 885 — 8y
0
That is before the if line ZarsBranchkin 885 — 8y
View all comments (3 more)
0
I'll do that. cc0de 35 — 8y
0
The number of speed does return into output on hit, but the joints don't break. cc0de 35 — 8y
0
I got it working! Turns out that velocity is different to vehicleseat speed. Thank you, Zars! cc0de 35 — 8y

Answer this question