I am trying to tilt the character vertically based on the camera LookVector, but for some reason when my value reaches 90 it wont go further
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local lerp = require(ReplicatedStorage.Utils.lerp)
local Player = game.Players.LocalPlayer or game.Players:GetPropertyChangedSignal("LocalPlayer"):Wait()
local Character = Player.Character
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local Camera = workspace.CurrentCamera
local MaxTilt = 25 -- clamp
local TiltIncrement = 1
local TiltMultiplier = 5 -- multiplying deltatime
local VerticalTilt = 0 -- tilt value
RunService.RenderStepped:Connect(function(deltaTime)
local cameraY = Camera.CFrame.LookVector.Y * TiltIncrement
local rootX, _, _ = HumanoidRootPart.RootJoint.C1:ToOrientation()
VerticalTilt = math.round(lerp(VerticalTilt, -cameraY * TiltIncrement, deltaTime * TiltMultiplier) * 1000) / 1000 -- for increasing / decreasing the amount of tilt linearly
local toSet = math.clamp(VerticalTilt + -math.deg(rootX), 90 - MaxTilt, MaxTilt + 90)
HumanoidRootPart.RootJoint.C1 = CFrame.Angles(math.rad(toSet), math.rad(180), 0) -- setting
end)