How can I force a player to look at a position in first person?

function MatchServer.RotatePlayerCamera(user,focusPosition)
	local character = user.Character
	
	local bg=Instance.new("BodyGyro")
	bg.cframe = CFrame.new(focusPosition)
	bg.Parent = character.HumanoidRootPart
	
	character:SetPrimaryPartCFrame(CFrame.new(character.HumanoidRootPart.Position, focusPosition))	
	user.CameraMode = Enum.CameraMode.LockFirstPerson
	
end

I am trying to find a way to force the player to look towards the focusPosition. This function currently turns the player’s body towards it, and locks the player to first person, but their first person camera points in whatever direction they were already looking.

The user is teleported to a location, and I just need their first person view to look at the part when they teleport. After that they should have complete control over their camera.

I’m not very familiar with manipulating cameras. If anyone knows how to achieve this it would be greatly appreciated. I searched for an answer but I couldn’t really find anything.

1 Like

you can manipulate cameras in the same way as parts with changing its CFrame

local camera = game.Workspace.CurrentCamera -- only works in local script
camera.CFrame = cframe
1 Like

Thank you! For anyone else with this issue, I used this answer to make this client-side function that seems to work.

function MatchClient.RotatePlayerCamera(focusPosition)
	local character = player.Character
	local camera = game.Workspace.CurrentCamera
	camera.CFrame = CFrame.lookAt(character.HumanoidRootPart.Position,focusPosition) 
end
1 Like

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