Making part go only in one angle

I’m trying to understand how to make part go only in one angle with a script

Thanks. :slight_smile:

Are you trying to make a Part move in a specific direction using a CFrame?
Here is a simple piece of code to make a part move up or down (or left or right)

**while true do
wait()
for i= 1, 300 do
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0,-0.1,0)
wait()
end
for i= 1, 300 do
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0,0.1,0)
wait()
end
end
**
or visit this DevHub page

What do you mean? Can you explain more thoroughly what you are looking for? Do you mean you want the part to move forward in the direction that it is facing?

Yes, I mean to make the part move only in the X direction

Position is defined with Vector3 values, Vector3(Xaxis,Yaxis,Zaxis). To move it along one axis just change one of this values.

local part = --define

while wait() do
     part.Position = part.Position + Vector3.new(0.5,0,0)
end

Still not working. I tried this script.

Any errors? You defined the part properly?