Making a parts Y orientation the same as the cameras

Basically the title. I want a part to rotate on its Y axis from the cameras rotation/orientation. But I cant figure this out since I’m very new to CFrames.

1 Like

Couldn’t you just set the part’s CFrame to the camera’s CFrame?

1 Like

But I only want the part to rotate on the Y axis. Not just the cameras CFrame

1 Like

Gotcha. You could probably do this with :ToEulerAnglesXYZ

local runService = game:GetService('RunService')

local camera = workspace.CurrentCamera

local part = workspace.Part
runService.RenderStepped:Connect(function()
    local cframe = camera.CFrame
    local x,y,z = cframe:ToEulerAnglesXYZ()
    part.Orientation = Vector3.new(0,math.deg(y),0)
end)

4 Likes

You can achieve this through CFrame.YVector. Will return the Y column of the CFrame matrix. Careful though as this returns radians, and your probably looking for degrees.

1 Like

Worked! :smiley: now I understand a bit better how CFrames work!

2 Likes

How would I turn that into a vector 3 since I want to Orientate a model?

1 Like

You could take the part’s orientation instead of its CFrame.

1 Like

No what I meant was how would I take Look, top, and right Variables and turn them into a vector3?

1 Like