How can I make the camera look at the right side of a part

I’m trying to use a viewport to show a model and I need it to show the right side of it

for the purpose of simplfying things i’ve been testing the camera script on workspace
ive tried that;

game.Workspace.Camera.CFrame = CFrame.lookAt(game.Workspace["Lee Enfield"].Rifle.Position ,game.Workspace["Lee Enfield"].Rifle.CFrame.RightVector)

also added offsets to the position and messed around with that line, that didnt work, it doesnt look directly at the right side of the weapon

I think this should work

game.Workspace.Camera.CFrame = CFrame.lookAt(game.Workspace["Lee Enfield"].Rifle.CFrame * CFrame.new(1,0,0), game.Workspace["Lee Enfield"].Rifle.Position)

i think you just had the at and lookat parameters back to front
sorry for edit

game.Workspace.Camera.CFrame = CFrame.lookAt(game.Workspace[“Lee Enfield”].Rifle.CFrame * CFrame.new(1,0,0), game.Workspace[“Lee Enfield”].Rifle.Position):1: invalid argument #1 to ‘lookAt’ (Vector3 expected, got CFrame)

It should be CFrame.new() rather than CFrame.lookAt()

game.Workspace.Camera.CFrame = CFrame.lookAt((game.Workspace["Lee Enfield"].Rifle.CFrame * CFrame.new(1,0,0)).Position, game.Workspace["Lee Enfield"].Rifle.Position)

Sorry, I forgot I left the first argument as a CFrame instead of Vector3.
Also changing the value of the CFrame.new(1,0,0) x value will increase the distance the camera is from the model.

1 Like