How to fix this Camera over Shoulder script?

My new project I’m working on has a system that I want to implement, where when a remote event to the client is fired, it makes the client’s camera over their shoulder. I made this work, however, I don’t know how to make the camera over the shoulder follow the player’s head and movements, instead of player being able to rotate around themselves.

My script

local remoteEvent = game.Workspace.RemoteEvents.RemoteCamera
local Players = game:GetService("Players")
local ContextActionService = game:GetService("ContextActionService")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")

local camera = workspace.CurrentCamera
local cameraOffset =, 2, 5)
local player = Players.LocalPlayer
 local function onNotifyPlayer(playerr)
print("Incoming eventw3t5")
local character = player.Character or player.CharacterAdded:wait()

local humanoid = character:WaitForChild("Humanoid")
local rootPart = character:WaitForChild("HumanoidRootPart")
humanoid.AutoRotate = false

local cameraAngleX = 0
local cameraAngleY = 0

local function playerInput(actionName, inputState, inputObject)
	-- Calculate camera/player rotation on input change
	if inputState == Enum.UserInputState.Change then
		cameraAngleX = cameraAngleX - inputObject.Delta.X
		-- Reduce vertical mouse/touch sensitivity and clamp vertical axis
		cameraAngleY = math.clamp(cameraAngleY-inputObject.Delta.Y*0.4, -75, 75)
		-- Rotate root part CFrame by X delta
		rootPart.CFrame = rootPart.CFrame * CFrame.Angles(0, math.rad(-inputObject.Delta.X), 0)
ContextActionService:BindAction("PlayerInput", playerInput, true, Enum.UserInputType.MouseMovement, Enum.UserInputType.Touch)

	if camera.CameraType ~= Enum.CameraType.Scriptable then
		camera.CameraType = Enum.CameraType.Scriptable
	local startCFrame = * CFrame.Angles(0, math.rad(cameraAngleX), 0) * CFrame.Angles(math.rad(cameraAngleY), 0, 0)
	local cameraCFrame = startCFrame:ToWorldSpace(, cameraOffset.Y, cameraOffset.Z))
	local cameraFocus = startCFrame:ToWorldSpace(, cameraOffset.Y, -10000))
	camera.CFrame =, cameraFocus.Position)

local function focusControl(actionName, inputState, inputObject)
    -- Lock and hide mouse icon on input began
    if inputState == Enum.UserInputState.Begin then
	    UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
	    UserInputService.MouseIconEnabled = false
	    ContextActionService:UnbindAction("FocusControl", focusControl, false, 
Enum.UserInputType.MouseButton1, Enum.UserInputType.Touch, Enum.UserInputType.Focus)
ContextActionService:BindAction("FocusControl", focusControl, false, 
Enum.UserInputType.MouseButton1, Enum.UserInputType.Touch, Enum.UserInputType.Focus)

GIF/Visual Representation of what it looks like now VS what I want it to be.


The issus is that you have the camera over the shoulder but you dont have it locked to the mouse, like shiftlocking.

How would I lock it to the mouse?

UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter

You could also find it on the developer API if you need anymore help, UserInputService | Documentation - Roblox Creator Hub

If you look at the script that’s already in it, but doesn’t do anything.