Require help creating a working camera offset

In a soul eater game I’m developing for, I’m developing a movement system that works and acts smoothly. However, a big problem arises when I attempt to offset the camera in shift lock mode, where the player will lag behind the cursor when running. I’m currently using Humanoid.CameraOffset, but as that’s not working, I’m curious as to how I would go about creating a lagless offset. Here’s my code:

	Player.PlayerScripts.PlayerModule.CameraModule.MouseLockController.BoundKeys.Value = "LeftAlt, RightAlt"
	Mouse.Icon = "rbxassetid://46537754"
	if UserInputService.MouseBehavior == Enum.MouseBehavior.LockCenter then
		Player.CameraMinZoomDistance = 10
		Player.CameraMaxZoomDistance = 10
		Humanoid.CameraOffset =, 1.75, 0)
	elseif UserInputService.MouseBehavior == Enum.MouseBehavior.Default then
		Player.CameraMinZoomDistance = 10
		Player.CameraMaxZoomDistance = 32
		if not Humanoid.AutoRotate and not Player.InCutscene.Value then
			Humanoid.AutoRotate = true
		if Humanoid.CameraOffset.Magnitude > 0 then
			Humanoid.CameraOffset =, 0, 0)

Here’s what it does in the studio:

Here’s the script I use in my game. It works by creating 3 number values and using those as the offset of the camera. You can change the values to whatever you need.

-- in a script in StarterPlayerScripts
-- this script is for setting the camera's offset

local plr = game.Players.LocalPlayer
local Camera = workspace.CurrentCamera
local context = game.ContextActionService
local rs = game["Run Service"]

local sensitivity = 0.4
local xAngle = 0
local yAngle = 0

-- adjust these values to change the offset of the camera
local ValX ="NumberValue", plr)
ValX.Name = "CameraPosValu1X"
ValX.Value = 2

local ValY ="NumberValue", plr)
ValY.Name = "CameraPosValueY"
ValY.Value = 0

local ValZ ="NumberValue", plr)
ValZ.Name = "CameraPosValueZ"
ValZ.Value = 8

local cameraPos =,ValY.Value,ValZ.Value)

Camera.CameraType = Enum.CameraType.Scriptable

context:BindAction("CameraMovement", function(_,_,input)
	xAngle = xAngle - input.Delta.x*sensitivity
	yAngle = math.clamp(yAngle - input.Delta.y*sensitivity,-80,80)
end, false, Enum.UserInputType.MouseMovement)

	local m = plr:GetMouse()
	game.UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
	local c = plr.Character or plr.CharacterAdded:Wait()
	local rootPart = c:FindFirstChild("HumanoidRootPart")

	if c and rootPart then
		local startCFrame = +,2,0)))*CFrame.Angles(0, math.rad(xAngle), 0)*CFrame.Angles(math.rad(yAngle), 0, 0)

		cameraPos =,ValY.Value,ValZ.Value)

		local cameraCFrame = startCFrame + startCFrame:VectorToWorldSpace(,cameraPos.Y,cameraPos.Z))
		local cameraFocus = startCFrame + startCFrame:VectorToWorldSpace(,cameraPos.Y,-50000))

		Camera.CFrame =,cameraFocus.p)
-- in a local script in StarterCharacterScripts
-- this script locks the player's character and turns it to where their camera is facing

local plr = game.Players.LocalPlayer
local cam = workspace.CurrentCamera
game["Run Service"].RenderStepped:Connect(function()
	if plr.Character then
		local rootPart = plr.Character:WaitForChild("HumanoidRootPart")
		if rootPart then
			local lookingCFrame = CFrame.lookAt(rootPart.Position, cam.CFrame:PointToWorldSpace(, 0, -100000)))
			rootPart.CFrame = CFrame.fromMatrix(rootPart.Position, lookingCFrame.XVector, rootPart.CFrame.YVector)

All credit goes to Gokhai Gaming on Youtube.

Mouse Lock offset can be changed into the default camera module script.

  • Go in play mode on studio and copy these 2 scripts, which are in Player > you > PlayerScripts

  • Past them into the “StarterPlayerScripts”

  • Go into the PlayerModule > CameraModule

  • Scroll to the line 492 in the CameraModule

  • Copy - past these lines of code into the “Update(dt)” function

	if UserInputService.MouseBehavior == Enum.MouseBehavior.LockCenter then
		--self.activeCameraController:SetIsMouseLocked(true) --Optionnal
		self.activeCameraController:SetMouseLockOffset(, 1.75, 0))
	elseif UserInputService.MouseBehavior == Enum.MouseBehavior.Default then
		--self.activeCameraController:SetIsMouseLocked(false) --Optionnal
		self.activeCameraController:SetMouseLockOffset(, 0, 0))