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

How do I run a function every time the position of a part changes?

Asked by 4 years ago

I'm trying to run a function which would change the direction of body velocities every time the vehicle had moved so it could get around corners of a track. I've been trying to check the position of the seat that controls the vehicle, and run the function every time its position changes. I wanted to do this rather than checking the direction per frame because it would be more efficient. This is the code that I could come up with but, it doesn't work and I'm unsure how I could go about doing this properly because I've been told that changes to properties by the physics engine doesn't fire events.

local seat = script.Parent.VehicleSeat

seat:GetPropertyChangedSignal("Position"):Connect(function()
    print("moved")
end)

Answer this question