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
Try using lowercase for magnitude like: Velocity.magnitude. I'm not 100% sure, maybe there has been added Magnitude, but case matters. ZarsBranchkin 885 — 8y
0
nothing happens, it's not that but thanks cc0de 35 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

The code seems fine so the issue should be the implementation/theory. Have you checked the value of Velocity.Magnitude? Print this out before your if statement, as this will be the true indicator as to why your if statement never equals true.

0
I tried that. Nothing prints. cc0de 35 — 8y
Ad

Answer this question