Got it! You want the camera to be offset (e.g., slightly to the right) while forcing the character to always face away from the camera (as if the player is looking at the character's back).
This means:
- The camera is positioned behind and slightly to the right of the character.
- The character always faces away from the camera (like in a third-person game).
- The mouse controls the camera rotation (up/down & left/right).
✅ Revised Solution (Forced Behind-View Camera)
Here’s the updated script that forces the character to face away from the camera while keeping the camera offset:
📜 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 (negative Z = behind)
local SENSITIVITY = 0.002
local MAX_Y_ANGLE = math.rad(80) -- Max look up
local MIN_Y_ANGLE = math.rad(-80) -- Max look down
-- Internal
local cameraAngleX = 0
local cameraAngleY = 0
local isRightMouseDown = false
-- Disable default camera and lock mouse
camera.CameraType = Enum.CameraType.Scriptable
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
-- Mouse input handling
UserInputService.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton2 then
isRightMouseDown = true
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton2 then
isRightMouseDown = false
end
end)
-- Camera rotation from mouse movement
UserInputService.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement and isRightMouseDown 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 direction
RunService.RenderStepped:Connect(function()
if not character or not rootPart then return end
-- Calculate camera position (behind & offset)
local cameraCFrame = CFrame.new(rootPart.Position)
* CFrame.Angles(0, cameraAngleX, 0)
* CFrame.Angles(cameraAngleY, 0, 0)
* CFrame.new(CAMERA_OFFSET)
-- Point camera at the character's back
local lookAtPoint = rootPart.Position + Vector3.new(0, 1.5, 0) -- Look at chest level
camera.CFrame = CFrame.new(cameraCFrame.Position, lookAtPoint)
-- Force character to face away from the camera
local lookDirection = (lookAtPoint - cameraCFrame.Position).Unit
rootPart.CFrame = CFrame.new(rootPart.Position, rootPart.Position - lookDirection * Vector3.new(1, 0, 1))
end)
🔧 Key Changes
-
Camera Offset (CAMERA_OFFSET)
- Changed
Z to negative (-6) to place it behind the player.
X (2) moves it slightly to the right.
-
Character Faces Away from Camera
- The character now always looks in the opposite direction of the camera.
- This is done by setting
rootPart.CFrame to face -lookDirection.
-
Mouse Controls
- Right-click + drag rotates the camera.
- The character does not turn unless the camera moves.
🎮 How It Works
- The camera is positioned behind and to the right of the player.
- The character always faces away from the camera (like in a third-person game).
- Mouse movement rotates the camera up/down & left/right.
- The character’s movement is unaffected (WASD still works normally).
🚀 Next Steps
- Add a crosshair (using a
ScreenGui).
- Smooth camera movement with
CFrame:Lerp().
- Toggle between left/right shoulder (swap
CAMERA_OFFSET.X between 2 and -2).
Would you like any of these features added? 🚀