How do I move a part forwards?

Hello I’m trying to move a part… but it’s not what you think! moving a part forward works, but I want to move it forwards in whatever direction its looking. so If its looking sideways, move it sideways forward. Here is an example:
image
image
see how to part moves forwards in the direction the part is looking and not just increasing its Z axis.

You would have to multiply a CFrame relative to that part’s CFrame.

Consider that the direction the part is moving towards is relative to it’s z-axis. Your code would look something like this:

part.CFrame = part.CFrame * CFrame.new(0, 0, -1) -- Moves part forward by 1 stud
part.CFrame *= CFrame.new(0, 0, -1) -- This does the same thing

You can do this with any axis relative to the part’s CFrame.
More here.

It may have been 3 years lmao, but for the sake of roblox devs who don’t know how to do this, I should help

script.Parent.CFrame = script.Parent.CFrame + script.Parent.CFrame.ZVector * 10

10 is the distance in studs adjust it, and you can use either XVector for the local X axis, YVector, etc.

-- game.StarterPlayerScripts.LocalScript
local rns = game:GetService("RunService")
local part = workspace:WaitForChild("Part")
local speed = 1

while true do rns.Stepped:Wait()
	part.CFrame = part.CFrame + part.CFrame.LookVector * speed 
end

Whatever way you face this, it will go that way..

Hey, 4 years old.. :face_with_crossed_out_eyes: