Camera follow script breaking character rotation

I’m trying to make a camera script that will let the camera slightly lag behind the player smoothly, but the character will not turn when shift lock gets used, only when holding right click will the character move with the camera.

Short video of the issue

Heres my current code

local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart = Character.Head
local Camera = game.Workspace.CurrentCamera

Camera.CameraType = Enum.CameraType.Custom

local CameraContainer = Instance.new("Part")
CameraContainer.Size = Vector3.new(.1,.1,.1)
CameraContainer.Color = Color3.new(0,50,0)
CameraContainer.Transparency = .5
CameraContainer.CanCollide = false
CameraContainer.CanQuery = false
CameraContainer.Anchored = false
CameraContainer.Massless = true

local PlayerAttachment = Instance.new("Attachment")
local TargetAttachment = Instance.new("Attachment")
local Aligner = Instance.new("AlignPosition")

CameraContainer.Parent = HumanoidRootPart

local weld = Instance.new("Weld")
weld.Part0 = Character.Head
weld.Part1 = CameraContainer

CameraContainer.CFrame = HumanoidRootPart.CFrame + Vector3.new(0,0,-5)

PlayerAttachment.Parent = HumanoidRootPart
TargetAttachment.Parent = CameraContainer

Aligner.Parent = CameraContainer
Aligner.Enabled = true
Aligner.Attachment0 = TargetAttachment
Aligner.Attachment1 = PlayerAttachment

BodyGyro = Instance.new("BodyGyro")
BodyGyro.MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
BodyGyro.CFrame = CFrame.new(HumanoidRootPart.Position,CameraContainer.Position)
BodyGyro.P = 13000
BodyGyro.D = 100
BodyGyro.Parent = Aligner
BodyGyro.Name = "Dir"

workspace.CurrentCamera.CameraSubject = CameraContainer
workspace.CurrentCamera.FieldOfView = 90


Any help is appreciated.

1 Like