Why is this part becoming rotated when moved with a script?

I’m trying to make a part which moves and then instantly goes back to its original spot and does this forever. This is my current script for doing so:

while true do
	for i= 1, 50 do
		script.Parent.CFrame = CFrame.new(0,5,0)
	end
	for i= 1, 50 do
		script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0.3,0,0)
		task.wait()
	end
end

The problem I’m having is that for some reason the part gets rotated when I run the project.

The part before running the project:

The part while running the project:
2023-03-22 23-33-38

I’m not very knowledgeable with cframe stuff so if anyone knows what’s doing this and how to fix it that would be greatly appreciated.

In the third line script.Parent.CFrame = CFrame.new(0,5,0)

That CFrame has no orientation properties, only the position properties 0,5,0.
Check what CFrame could use to work in the documentation.

i put the script in a different part and it worked because the first part i tried on had been rotated while this one was not. so yeah, i probably needed to specify the orientation or just pick the easy way of just using a part with 0,0,0 orientation

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