How do I make a part move relative to its rotation?

How would I be able to make a part that moves forwards depending on its rotation?

Part.Position += Part.CFrame.LookVector * Units

Well you would typically use the cframe property of the part to specify its position and rotation, and then use a script to update the cframe based on its current rotation.

So would I have to get a part’s lookvector and multiply it?

Yep. You can get the lookvector property of a part’s cframe to get the direction it’s facing, and then multiply it by a scalar value (e.g. units in your example) to specify how much you want the part to move in that direction. The resulting vector can then be added to the position property of the part to update its position.


local part = script.Parent

while true do
	part.CFrame = part.CFrame + part.CFrame.LookVector * Units

Basically this script updates the position of the part every 0.1 seconds, moving it in the direction it’s facing by units each time.


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