Problem with cframes direction

Basically, I want that yellow motor on the side to stay on the direction. If anyone know how to fix this please do tell me

the script for this is rather simple, what should be changed so it work like I intended?

local a = math.rad(90)
script.Parent.CFrame = CFrame.new(script.Parent.Position,game.Workspace.asdaw.Position)*CFrame.Angles(a,0,0)

You must first pick an axis that it will rotate around, I assume you want it to always rotate around the side with the welds. In that case you can use lookAt with that direction as the Up argument. The argument must be in the same space as the other arguments to lookAt.

2 Likes

do you mind making a code example? I dont quite understand (edit the one I already made)

Do you mean that yellow motor stay at the right side of the part or look to object as right side

--You must only calculate this once, if you calculate it every time the part will oscillate
local upDirection = part.CFrame:VectorToWorldSpace(Vector3.xAxis)

part.CFrame = CFrame.lookAt(part.Position, targetWorldSpace, upDirection)
1 Like

another problem arise after using this one

Is it possible to fix this on all axis?