Have Part Face Camera Direction?

How would I make it such that a part would face the direction the camera is looking at? For example, I’d sit in a seat and move my camera to face left. As I turn my camera, the part would also turn to the left.

My code so far (obv not working):

script.Parent:GetPropertyChangedSignal('Occupant'):Connect(function()
	local occupant = script.Parent.Occupant
	local char
	
	local s, r = pcall(function()
		char = occupant.Parent
	end)
	
	if s then
		while wait() do
			local cf = workspace.CurrentCamera.CFrame
			script.Parent.CFrame:Lerp(CFrame.lookAt(script.Parent.Orientation, Vector3.new(cf)), 0.5)
		end
    end
end)

I’m definitely not the best at CFrames/Vector3’s so don’t judge lol

1 Like

Maybe on the line where you are setting the part’s CFrame, write it like this?

script.Parent.CFrame:Lerp(CFrame.lookAt(script.Parent.Position,script.Parent.Position+cf.lookVector),0.5)
2 Likes

Nope, it appears to do nothing.

1 Like

How about just set the CFrame like this?

script.Parent.CFrame = CFrame.lookAt(script.Parent.Position,script.Parent.Position+cf.lookVector)
1 Like

robloxapp-20210523-1540571.wmv (1.7 MB)
The seat just repeatedly moves backward and looks at a 35 degree-ish angle toward the ground.

1 Like

Not sure if this works, i havent tested it but i think it works

script.Parent:GetPropertyChangedSignal('Occupant'):Connect(function()
	local occupant = script.Parent.Occupant
	local char
	
	local s, r = pcall(function()
		char = occupant.Parent
	end)
	
	if s then
		while wait() do
			local cf = workspace.CurrentCamera.CFrame
            local X,Y,Z = cf:ToEulerAnglesXYZ()
			script.Parent.Orientation = script.Parent.Orientation:Lerp(Vector3.new(math.deg(X), math.deg(Y), math.deg(Z))), 0.5)
		end
    end
end)
1 Like

Hmm, it appears to glitch the player out and cause the part (and character welded to it) to jitter around.

Printing X, Y, and Z print the exact same thing every time no matter the camera angle:

image