-
**What do you want to achieve?
I want to achieve over the shoulder smooth shiftlock. -
**What is the issue?
-
**What solutions have you tried so far?
I looked for solutions but no one seems be trying to do what im doing.
local uis = game:GetService("UserInputService")
local camera = workspace.CurrentCamera
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local hrp = character:WaitForChild("HumanoidRootPart")
local offset = CFrame.new(Vector3.new(2, 5, 7))
local rotationOffset = CFrame.Angles(math.rad(-30), 0, 0)
local finalOffset = offset * rotationOffset
local sensitivity = 0.1
camera.CameraType = "Scriptable"
camera.CFrame = character:FindFirstChild("HumanoidRootPart").CFrame * finalOffset
if humanoid.Health > 0 then
local mouseStartPosition = uis:GetMouseLocation()
uis.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
local mouseEndPosition = uis:GetMouseLocation()
local mouseDelta = (mouseEndPosition - mouseStartPosition)
local targetCFrame = finalOffset
camera.CFrame = camera.CFrame:Lerp(hrp.CFrame * targetCFrame, 0.1)
uis.MouseBehavior = Enum.MouseBehavior.LockCenter
local newRotationY = hrp.CFrame:PointToWorldSpace(hrp.Position) + Vector3.new(mouseDelta.x * sensitivity, 0, 0)
hrp.CFrame = CFrame.new(hrp.Position, newRotationY)
mouseStartPosition = mouseEndPosition
end
end)
end