Smooth shiftlock V0.1

this is a simple stuff, basically replicate the shiftlock system but smoothly

local plr = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local cha = plr.Character or plr.CharacterAdded:Wait()
local hrp = cha:WaitForChild("HumanoidRootPart")
local humanoid = cha.Humanoid

local camera = workspace.CurrentCamera

local uis = game:GetService("UserInputService")
local tweenserv = game:GetService("TweenService")
local run = game:GetService("RunService")



local isLocked = false

humanoid.AutoRotate = true


function shiftlock(active)
	local offset = Vector3.new(1.75,.25,0)
	if active then
		tweenserv:Create(humanoid,TweenInfo.new(.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0),{CameraOffset = humanoid.CameraOffset + offset}):Play()
		
		run.RenderStepped:Connect(function()
		uis.MouseBehavior = Enum.MouseBehavior.LockCenter
		
		humanoid.AutoRotate = false
		
		local _, y = workspace.CurrentCamera.CFrame.Rotation:ToEulerAnglesYXZ()
		hrp.CFrame = CFrame.new(hrp.Position) * CFrame.Angles(0,y,0)
		
		end)
		
	else
		tweenserv:Create(humanoid,TweenInfo.new(.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0),{Position = camera.Position + offset}):Play()
		uis.MouseBehavior.Value = Enum.MouseBehavior.LockCenter

		humanoid.AutoRotate = true

	end
end

task.wait(3)
shiftlock(true)

how it works: the only shiftlock parameter is a boolean value, this means this can be switched to On and off ( true or false)

Not fully working after changing Humanoid.CameraOffset

do you place this in startercharacterscripts?

yeah, also in StarterCharacterScripts or StarterGui

can be also used in a tool to active the shiftlock