game:GetService("RunService"):BindToRenderStep("CameraOffset", Enum.RenderPriority.Camera.Value - 1, function()
if plr.Character and plr.Character:FindFirstChild("Humanoid") then
local offset = Vector3.new(C.CurrentXOffset.Value, 0, 0)
TS:Create(plr.Character.Humanoid, TweenInfo.new(.1), {CameraOffset = offset}):Play()
if C.ShiftLock == true then
local currentCFrame = plr.Character.PrimaryPart.CFrame
local targetCFrame = CFrame.new(plr.Character.PrimaryPart.CFrame.p, plr.Character.PrimaryPart.CFrame.p + Vector3.new(currentCamera.CFrame.LookVector.X, 0, currentCamera.CFrame.LookVector.Z))
local newRotation = currentCFrame:Lerp(targetCFrame, 10 * game:GetService("RunService").Heartbeat:Wait())
plr.Character.PrimaryPart.CFrame = CFrame.new(currentCFrame.p, newRotation.p + newRotation.LookVector)
end
end
end)
So I got something working, though I was editing it a ton for me to work in studio, so you will have to adjust it to your needs, anyway this is what I got:
local plr = game.Players.LocalPlayer
local currentCamera = workspace.CurrentCamera
game:GetService("RunService"):BindToRenderStep("CameraOffset", Enum.RenderPriority.Camera.Value - 1, function()
if plr.Character then
plr.Character.Humanoid.AutoRotate = false
local offset = Vector3.new(1, 0, 0)
plr.Character.Humanoid.CameraOffset = offset
local currentCFrame = plr.Character.PrimaryPart.CFrame
local targetCFrame = CFrame.new(plr.Character.PrimaryPart.CFrame.p, plr.Character.PrimaryPart.CFrame.p + Vector3.new(currentCamera.CFrame.LookVector.X, 0, currentCamera.CFrame.LookVector.Z))
local newRotation = currentCFrame:Lerp(targetCFrame, 10 * game:GetService("RunService").RenderStepped:Wait())
plr.Character.PrimaryPart.CFrame = CFrame.new(plr.Character.PrimaryPart.Position, newRotation.p + newRotation.LookVector)
end
end)
Just on a side note, the further you offset the camera from the player, the choppier it gets. So you might have to fix that as well, probably by speeding up the lerp might fix it, something around 10-30 works best imo.