How to force shiftlock

I have a custom Camera script and I would like for it to have shiftlock that works how shiftlock normally does, but I don’t know how to cause the camera to enter shiftlock.

1 Like

That method seems wonky, I found one that fits perfectly with what I’m doing but for some reason doesn’t work on death.

function shiftLock(active) --Toggle shift.lock function
	print(active)
	if active then		
		hum.CameraOffset = Vector3.new(1.75,0,0) -- I assume this is about the right camera offset.
		hum.AutoRotate = false --Disable the automatic rotation since we are the ones setting it.
			RunService:BindToRenderStep("ShiftLock", Enum.RenderPriority.Character.Value, function()
			UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter --Set the mouse to center every frame.

			local _, y = workspace.CurrentCamera.CFrame.Rotation:ToEulerAnglesYXZ() --Get the angles of the camera
			root.CFrame = CFrame.new(char:WaitForChild("Humanoid").RootPart.Position) * CFrame.Angles(0,y,0) --Set the root part to the camera's rotation
		end) 
	else

		hum.CameraOffset = Vector3.new(0,0,0) --Move the camera back to normal.
		RunService:UnbindFromRenderStep("ShiftLock") -- Allow mouse to move freely.
		UserInputService.MouseBehavior = Enum.MouseBehavior.Default -- Let the mouse move freely
		hum.AutoRotate = true --Let the humanoid handle the camera rotations again.
	end
end
2 Likes

Add the script in StarterCharacterScripts so it runs every time the player character gets added, and thus resets.

1 Like

It’s in StarterPlayer but I don’t see how that makes a difference

Add it in StarterCharacterScripts. In StarterPlayer it will only run once, and in StarterCharacterScripts it will run every time the character dies.

1 Like

Is there anyway to get it working in StaterPlayer for neatness I’d perfer it to be with the actual CameraScript rather than a separate one