Trying to point player's camera towards a part

I’m trying to point the player’s camera towards a part in workspace, like a tween, so it slowly moves there.

My code is below.

local Head = Vector3.new(script.Parent:FindFirstChild("Head").Position)
local AHead = Vector3.new(game.Workspace:FindFirstChild("Model").Head.Position)
local LookAt = CFrame.new(Head,AHead)
print(LookAt)
game:GetService("TweenService"):Create(game.Workspace.Camera,TweenInfo.new(2),{CFrame = LookAt}):Play()
task.wait(2)
end)

The Head Variable is our character’s head.
The AHead Variable is the character’s head i’m trying to look at.

The tween works fine, however the positioning i’m doing isn’t working. And beyond that I don’t know where to go.

I’ve searched forever on devforum on solutions, couldn’t find one, please help.

1 Like

Position is already a Vector3, you shouldn’t wrap a Vector3.new around it for the first two lines. I’m not sure if that changes anything.

Another possible issue is that you probably intended your LookAt variable to use the camera’s current position, not the character’s head.

Also, a nitpick, but when accessing the camera, you should use workspace.CurrentCamera.

1 Like

That is almost the solution. I’m a bit new to scripting so I don’t know everything, Also how will I get the currentcamera’s position? not the CFrame of it.

Camera.CFrame.Position should work

You need to make the camera type scriptable if you want to modify any properties of it, including the cframe. To revert back to normal, simply set it to custom. Note that setting it to custom will jump the camera which may not be ideal so it might be a good idea to record the current camera cframe before tweening and tween back in a sense when done.

1 Like

You will have to make the camera type scriptable and add a offsetting factor so it doesn’t put your camera inside the part.

Hey thanks that worked, so much for a caveman huh, have fun with 6 solutions