Can someone help me fix this script; This script makes a smooth camera delay, BUT it makes shift lock break (shift lock keybind and icon work, but my player’s body isn’t rotating the way my shiftlocked camera is facing. only faces the way my shiftlocked camera is facing if i jump while walking) PLS HELP! ty
Here’s my script:
---------
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local camera = workspace.CurrentCamera
local head = script.Parent:WaitForChild("Head")
local subject = script:WaitForChild("Subject")
subject.Position = head.Position
local WEIGHT = 10
local function updateSubject()
if not Players.LocalPlayer or not Players.LocalPlayer.Character or not Players.LocalPlayer.Character:FindFirstChildOfClass("Humanoid") then
return
end
local targetPosition = head.CFrame * CFrame.new(0, 0, 0) -- Adjust the offset as per your need
subject.Position = subject.Position:Lerp(targetPosition.p, 1 / WEIGHT)
camera.CameraSubject = subject
end
RunService:BindToRenderStep("UpdateSubject", Enum.RenderPriority.Camera.Value, updateSubject)
I believe your script should not be a character script and rather a player script, but leaving that aside, it may be because you are not taking into account the camera offset that the shift lock applies and that is why it does not offset as it should.
I’m a little late but for anybody that’s facing the same issue:
you just need to add
if UserInputService.MouseBehavior == Enum.MouseBehavior.LockCenter then
local pitch, yaw, roll = camera.CFrame:ToEulerAnglesYXZ()
rootpart.CFrame = CFrame.new(rootpart.CFrame.p) * CFrame.Angles(0, yaw, 0)
end
to your updateSubject() function
---------
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local camera = workspace.CurrentCamera
local rootpart = script.Parent:WaitForChild("HumanoidRootPart")
local head = script.Parent:WaitForChild("Head")
local subject = script:WaitForChild("Subject")
subject.Position = head.Position
local WEIGHT = 10
local function updateSubject()
if not Players.LocalPlayer or not Players.LocalPlayer.Character or not Players.LocalPlayer.Character:FindFirstChildOfClass("Humanoid") then
return
end
local targetPosition = head.CFrame * CFrame.new(0, 0, 0) -- Adjust the offset as per your need
subject.Position = subject.Position:Lerp(targetPosition.p, 1 / WEIGHT)
camera.CameraSubject = subject
if UserInputService.MouseBehavior == Enum.MouseBehavior.LockCenter then
local pitch, yaw, roll = camera.CFrame:ToEulerAnglesYXZ()
rootpart.CFrame = CFrame.new(rootpart.CFrame.p) * CFrame.Angles(0, yaw, 0)
end
end
RunService:BindToRenderStep("UpdateSubject", Enum.RenderPriority.Camera.Value, updateSubject)