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
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)