To create a custom over-the-shoulder camera system in Roblox that mimics forced shift-lock, you'll need to:
- Disable the default camera and control scripts.
- Create a custom camera script that offsets the camera slightly to the right of the character.
- Force the character to face the camera's look direction.
- Allow vertical camera movement (mouse look up/down).
- Lock the mouse and use it for camera rotation.
✅ Step-by-Step Implementation
📁 File Structure
Place this in StarterPlayer > StarterPlayerScripts as a LocalScript.
📜 LocalScript: OverTheShoulderCamera.lua
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local player = Players.LocalPlayer
local camera = workspace.CurrentCamera
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local rootPart = character:WaitForChild("HumanoidRootPart")
-- Settings
local CAMERA_OFFSET = Vector3.new(2, 1.5, 6) -- Right, Up, Back
local SENSITIVITY = 0.002
local MAX_Y_ANGLE = math.rad(80)
local MIN_Y_ANGLE = math.rad(-80)
-- Internal
local cameraAngleX = 0
local cameraAngleY = 0
local isRightMouseDown = false
-- Disable default camera and controls
camera.CameraType = Enum.CameraType.Scriptable
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
-- Lock mouse on input
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if input.UserInputType == Enum.UserInputType.MouseButton2 then
isRightMouseDown = true
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton2 then
isRightMouseDown = false
end
end)
-- Mouse movement
UserInputService.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
local delta = input.Delta
cameraAngleX -= delta.X * SENSITIVITY
cameraAngleY = math.clamp(cameraAngleY - delta.Y * SENSITIVITY, MIN_Y_ANGLE, MAX_Y_ANGLE)
end
end)
-- Update camera and character rotation
RunService.RenderStepped:Connect(function()
if not character or not rootPart then return end
-- Calculate camera CFrame
local startCFrame = CFrame.new(rootPart.Position) * CFrame.Angles(0, cameraAngleX, 0) * CFrame.Angles(cameraAngleY, 0, 0)
local cameraCFrame = startCFrame:ToWorldSpace(CFrame.new(CAMERA_OFFSET))
local cameraFocus = startCFrame:ToWorldSpace(CFrame.new(CAMERA_OFFSET.X, CAMERA_OFFSET.Y, -10000))
camera.CFrame = CFrame.new(cameraCFrame.Position, cameraFocus.Position)
-- Force character to face camera direction
local lookVector = Vector3.new(math.sin(cameraAngleX), 0, math.cos(cameraAngleX)).Unit
rootPart.CFrame = CFrame.new(rootPart.Position, rootPart.Position + lookVector)
end)
✅ What This Does
- Camera is offset slightly to the right and behind the player.
- Mouse controls vertical and horizontal camera rotation.
- Character always faces the direction the camera is looking.
- No shift-lock toggle — it's always active.
- Right-click locks the mouse (optional, you can remove this if you want it always locked).
🛠 Optional Enhancements
- Add a crosshair using a ScreenGui.
- Smooth the camera with
CFrame:Lerp().
- Add a toggle key to enable/disable the system.
Let me know if you want to add zoom, shoulder switching, or weapon aiming next.