Problem with lookAt

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to make it so that camera faces the part
  2. What is the issue? Include screenshots / videos if possible!

My lack of understanding and so It asks for orientation, but I want that the player’s camera moves to “bob” position and it looks straight.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Tried digging up memories, didn’t work
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
task.wait(1)
local player = Players.LocalPlayer
local camera = workspace.CurrentCamera
local bob = workspace.bob


camera.CFrame = CFrame.lookAt(bob.Position,camera.CFrame.Rotation)

I want so that position moves to bob, but it looks straight just like when a player respawned and looks straight.

If you want the camera to look at Bob, you will have to update the camera’s CFrame every frame.

Try this:

local RunService = game:GetService("RunService")

local bob = workspace:WaitForChild("bob")

RunService:BindToRenderStep("RotateCamera", Enum.RenderPriority.Camera.Value + 1, function(deltaTime: number)
	workspace.CurrentCamera.CFrame = CFrame.lookAt(workspace.CurrentCamera.CFrame.Position, bob.Position)
end)

Also, if you take a look at the documentation, you will see that the lookAt constructor has two required parameters:

You should first pass the Position (as Vector3) of the new CFrame and then the position (Vector3) to look at.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.