Im making a custom camera script, the only thing i can’t figure out how to do is to make the player rotate while in shift lock. Sometimes it will work correctly, the player will only look forward relative to the camera, but most times it will rotate the player weirdly. The rest is fine,
while RunService.RenderStepped:Wait() do
local dt = tick() - pastTick
if humanoid.MoveDirection.Magnitude > 0 and humanoid.WalkSpeed > 0 then
local target
if shiftLock then
target = (hrp.CFrame + Vector3.new(camera.CFrame.LookVector.X, hrp.CFrame.Position, camera.CFrame.LookVector.Z)).Position --This is not working
else
target = (hrp.CFrame + humanoid.MoveDirection.Unit).Position --Working fine
end
hrp.CFrame = hrp.CFrame:Lerp(CFrame.lookAt(hrp.CFrame.Position, target), dt * deltaTimeScale)
local MoveDirection = hrp.CFrame:VectorToObjectSpace(humanoid.MoveDirection)
Tilt = Tilt:Lerp(CFrame.Angles(math.rad(-MoveDirection.Z) * MaxTiltAngle, math.rad(-MoveDirection.X) * MaxTiltAngle, 0), dt * deltaTimeScale)
elseif humanoid.MoveDirection.Magnitude == 0 then
Tilt = Tilt:Lerp(CFrame.new(), dt * deltaTimeScale)
end
RootJoint.C0 = RootC0 * Tilt
--[rest of the camera logic]
pastTick = tick()
end
Working:
Not Working: