Why Is My Camera Not Looking At Look Vector Position?

I am making a game and I’d like the player’s camera to look at a part. When the function StartGame() is called from a moduleScript, a RemoteEvent is fired to the client in the for loop. In the ClientEvent I’d like the player to look at the part specified in line 11. For some reason, all the other lines work but the look vector does nothing. I am calling the function StartGame() from the command bar as the server and then switching to the client.

Code that fires the RemoteEvent.

local enableCamera = game.ReplicatedStorage.RemoteEvents.enableCamera

for i,plr in pairs(plrs) do

    local chair = setup["Chair" .. i]
	
    plr.Character.HumanoidRootPart.CFrame = chair.Seat.Seat.CFrame
	
    enableCamera:FireClient(plr, setup.LookPoint)
	
end

Player Local Script (Inside a Folder in StarterGui/PlayerGui) that listens for client events on the RemoteEvent “enableCamera”. “RemoteEvents” in ReplicatedStorage is just a Folder.

local enableCamera = game.ReplicatedStorage.RemoteEvents.enableCamera

enableCamera.OnClientEvent:Connect(function(lookat)

    local plr = game.Players.LocalPlayer

    plr.PlayerGui.MouseUnlock.Enabled = true
    workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
    plr.CameraMode = Enum.CameraMode.LockFirstPerson

    workspace.CurrentCamera.CFrame = CFrame.new(workspace.CurrentCamera.CFrame.Position, lookat.Position)

end)

There are no errors to any of the scripts.

Command I am using in the Command Bar to call the function StartGame()

local gameAPI = require(game.ServerScriptService.gameAPI)                 
gameAPI.StartGame({game.Players.happyfloppy6}, workspace.Setup)

Hey happyfloppy6,

Sorry, unfortunately it is not immediately clear why you are having this issue. If you go into a blank baseplate map with a part name “Part” in the workspace and run this code (a copy of yours from above)

local plr = game.Players.LocalPlayer

wait(2)
print("Running")

workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
plr.CameraMode = Enum.CameraMode.LockFirstPerson

workspace.CurrentCamera.CFrame = CFrame.new(workspace.CurrentCamera.CFrame.Position, game.Workspace.Part.Position)

It functions as intended, however only once. This line here

plr.CameraMode = Enum.CameraMode.LockFirstPerson

Is overriding the Scriptable functionality of the camera. Removing this will solve the problem of the user being able to move their camera even in Scriptable mode.

Hi, thanks for replying. I understand that that script is preventing the user from changing the camera position themselves, as that is the intended functionality, however I wanted to make the camera look at the part: workspace.Setup.LookPoint, programmatically. After this, the camera should not be able to move at all.