I am looking for a way to accomplish a system where if you turn left, the waist Motor6D turns left but only by 20 degrees and the second you turn right, it starts turning right up until 20 degrees and vice versa. I’ve gotten part of it working, the only part I am struggling with is getting it to reset when you start slightly turning the opposite direction so the torso then starts turning that way. Any help would be greatly appreciated.
Running this in StarterCharacterScripts
local runService = game:GetService("RunService")
local uis = game:GetService("UserInputService")
local tweenService = game:GetService("TweenService")
uis.MouseBehavior = Enum.MouseBehavior.LockCenter
local function updateCamera()
local camera = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local rootPart = character:WaitForChild("HumanoidRootPart")
local desiredPosition = (camera.CFrame * CFrame.new(3,0.6,-1))
local _, waistYaw, _ = character.UpperTorso.Waist.C0:ToOrientation()
local _, camYaw, _ = camera.CFrame:ToOrientation()
local currentC0 = character.UpperTorso.Waist.C0
local MoveDirection = camYaw > 0.1 and 1 or -1
print(MoveDirection)
--# <\ Update the Waist normally
if math.deg(camYaw) <= 20 and math.deg(camYaw) >= -20 then
character.UpperTorso.Waist.C0 = CFrame.new(currentC0.Position) * CFrame.Angles(0, camYaw, 0)
else
--# <\ Waist limit reached
end
camera.CFrame = desiredPosition
rootPart.CFrame = CFrame.new(rootPart.CFrame.Position, rootPart.CFrame.Position + Vector3.new(camera.CFrame.LookVector.X,0,desiredPosition.LookVector.Z))
end
runService.RenderStepped:Connect(updateCamera)