local plr = game.Players.LocalPlayer local character = plr.Character if character:FindFirstChild("Animate") then character.Animate.Enabled = false end for i,v in pairs(character.Humanoid:GetPlayingAnimationTracks()) do v.TimePosition = 0 v:Stop() end local Player = game:GetService("Players").LocalPlayer local Character = Player.Character local Humanoid = Character:FindFirstChildOfClass("Humanoid") local Animator = Humanoid:FindFirstChildOfClass("Animator") local Player = game:GetService("Players").LocalPlayer local PitchRanges = { [0] = { TimePosition = 0, }, [90] = { TimePosition = 0.6 }, [180] = { TimePosition = 1.2 }, [270] = { TimePosition = 1.8 }, [360] = { TimePosition = 2.4 }, } local PitchDuration = 0.5 local AnimAngler = {} local function Increment90Bounds(Angle) --Returns the lower bound and upper bound of the angle in 90 degree increments --Basically gets a frame thats 1 angle below and 1 angle above to be interpolated return math.floor(Angle / 90) * 90, math.floor((Angle + 90) / 90) * 90 end local function ConvertTo360(Angle) --Converts a real number angle to a 360 degree one return Angle % 360 --((Angle % 360) + 360) % 360 end local function AdjustWeight(Track, Weight, FadeTime) -- simple helper for making sure weight never hits 0 and the track stops if Weight < 0.0001 then Weight = 0.0001 end Track:AdjustWeight(Weight, FadeTime) end local function getPitchAndYaw(limbCFrame, torsoCFrame) local worldDirection = -limbCFrame.UpVector local localDirection = torsoCFrame:VectorToObjectSpace(worldDirection) local pitch = math.asin(math.clamp(localDirection.Y, -1, 1)) local yaw if math.abs(localDirection.Y) > 0.999 then yaw = 0 else yaw = math.atan2(-localDirection.X, -localDirection.Z) end return math.deg(pitch), math.deg(yaw) end local function getPitchAndRoll(limbCFrame, torsoCFrame) local worldDirection = -limbCFrame.UpVector local localDirection = torsoCFrame:VectorToObjectSpace(worldDirection) local pitch = math.deg(math.atan2(-localDirection.Z, -localDirection.Y)) local roll = math.deg(math.asin(math.clamp(localDirection.X, -1, 1))) return pitch, roll end local function getPitchAndYawLookVector(localDirection) localDirection = typeof(localDirection) == "CFrame" and localDirection.LookVector or localDirection local pitch = math.asin(math.clamp(localDirection.Y, -1, 1)) local yaw if math.abs(localDirection.Y) > 0.999 then yaw = 0 else yaw = math.atan2(-localDirection.X, -localDirection.Z) end return math.deg(pitch), math.deg(yaw) end function AnimAngler.PitchAndYaw(AnimationId) local Character = Player.Character local Humanoid = Character:FindFirstChildOfClass("Humanoid") local Animator = Humanoid:FindFirstChildOfClass("Animator") local Angler = {} local Animation = Instance.new("Animation") Animation.AnimationId = "http?="..tostring(AnimationId) local Animation2 = Instance.new("Animation") Animation2.AnimationId = "http="..tostring(AnimationId) local Track1 = Animator:LoadAnimation(Animation) Track1.Looped = true Track1:Play(0, 1, 0) Track1.Priority = 5 local Track2 = Animator:LoadAnimation(Animation2) Track2.Looped = true Track2:Play(0, 1, 0) Track2.Priority = 5 function Angler:SetRotation(Pitch, Yaw) Yaw = ConvertTo360(Yaw) Pitch = ConvertTo360(Pitch) local LowerPitch, UpperPitch = Increment90Bounds(Pitch) if UpperPitch > 360 then UpperPitch = UpperPitch % 360 end local TimePos1, TimePos2 = PitchRanges[LowerPitch].TimePosition, PitchRanges[UpperPitch].TimePosition local YawIndex = (Yaw / 360) * PitchDuration Track1.TimePosition = TimePos1 + YawIndex Track2.TimePosition = TimePos2 + YawIndex --Now for blending local Alpha = (Pitch - LowerPitch) / 90 AdjustWeight(Track1, 1 - Alpha, 0.0001) AdjustWeight(Track2, Alpha, 0.0001) end Angler:SetRotation(0, 0) return Angler end function AnimAngler.PitchAndRoll(AnimationId) local Character = Player.Character local Humanoid = Character:FindFirstChildOfClass("Humanoid") local Animator = Humanoid:FindFirstChildOfClass("Animator") local Angler = {} local Animation = Instance.new("Animation") Animation.AnimationId = "http?="..tostring(AnimationId) local Animation2 = Instance.new("Animation") Animation2.AnimationId = "http="..tostring(AnimationId) local Track1 = Animator:LoadAnimation(Animation) Track1.Looped = true Track1:Play(0, 1, 0) Track1.Priority = 5 local Track2 = Animator:LoadAnimation(Animation2) Track2.Looped = true Track2:Play(0, 1, 0) Track2.Priority = 5 function Angler:SetRotation(Pitch, Roll) Roll = ConvertTo360(Roll) Pitch = ConvertTo360(Pitch) local LowerPitch, UpperPitch = Increment90Bounds(Pitch) if UpperPitch > 360 then UpperPitch -= 360 end local TimePos1, TimePos2 = PitchRanges[LowerPitch].TimePosition, PitchRanges[UpperPitch].TimePosition local RollIndex = (Roll / 360) * PitchDuration Track1.TimePosition = TimePos1 + RollIndex Track2.TimePosition = TimePos2 + RollIndex --Now for blending local Alpha = (Pitch - LowerPitch) / 90 AdjustWeight(Track1, 1 - Alpha, 0.0001) AdjustWeight(Track2, Alpha, 0.0001) end Angler:SetRotation(0, 0) return Angler end return AnimAngler