Shoulder cam not working

So, I’m trying to make a shoulder cam whenever my tool is equipped, and return the camera to normal when it’s unequipped. It works when it’s equipped, but it doesn’t work when it’s unequipped. Along with this, the camera is constantly zooming out when equipped. All help appreciated!

Equip:

local RunService = game:GetService("RunService")
		local RunService = game:GetService("RunService")
		local UserInputService = game:GetService("UserInputService")
		local cam = workspace.CurrentCamera
		local player = game.Players.LocalPlayer
		local thirdPersonCameraOffset = CFrame.new(2,0,8.5)

		cam.CameraType = Enum.CameraType.Scriptable

		RunService.RenderStepped:Connect(function()
			cam.CFrame = cam.CFrame * thirdPersonCameraOffset
			UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
		end)

Unequip:

local RunService = game:GetService("RunService")
		local cam = workspace.CurrentCamera
		local player = game.Players.LocalPlayer
		local thirdPersonCameraOffset = CFrame.new(2,0,8.5)

		cam.CameraType = Enum.CameraType.Custom
		player.CameraMode = Enum.CameraMode.Classic

		RunService.RenderStepped:Connect(function()
			cam.CFrame = cam.CFrame - thirdPersonCameraOffset
		end)
1 Like

You should use:

So equip:

local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local cam = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local thirdPersonCameraOffset = CFrame.new(2,0,8.5)

cam.CameraType = Enum.CameraType.Scriptable

RunService:BindToRenderStep("ShoulderCam", Enum.RenderPriority.Camera.Value -1, function()
    cam.CFrame = player.Character.PrimaryPart.CFrame
    UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
end)

unequip:

local RunService = game:GetService("RunService")
local cam = workspace.CurrentCamera
local player = game.Players.LocalPlayer

cam.CameraType = Enum.CameraType.Custom
player.CameraMode = Enum.CameraMode.Classic

RunService:UnbindFromRenderStep("ShoulderCam")
1 Like

On the line where it’s binding it, I get this error:
attempt to perform arithmetic (sub) on EnumItem and number

sorry change it to: Enum.RenderPriority.Camera.Value -1

I’ve now got a problem where the cam’s infinitely going out

Change:

RunService:BindToRenderStep("ShoulderCam", Enum.RenderPriority.Camera.Value -1, function()
    cam.CFrame = player.Character.PrimaryPart.CFrame * thirdPersonCameraOffset

Overall very good! But, the problem is that when the player pressed A or D, the camera spins wildly. Secondly, is there a way to make it so you can move the camera around?

Camera code starts getting complicated fast, you can but I would advice you to use the camera types already in Roblox.