My animation keeps jittering, i dont know if its because how i switch between animation, i dont know how i would go about lerping weights, but it looks smooth and then it does a little jitter, and if i put my mouse on the gui and off it quickly it breaks the animation, is there a better way to do it
local VPMS = {}
function VPMS.Start(Viewport : ViewPortFrame, Worldmode : WorldModel, FadeFrame : Frame, ImgButton : ImageButton, AnimFolder : Folder, Animator : Animator)
--//VARIABLES//--
local Context_Action_Service = game:GetService("ContextActionService")
local StopMoving = "freezeMovement"
local IdleAnim = Animator:LoadAnimation(AnimFolder:WaitForChild("Idle"))
local MouseOnAnim = Animator:LoadAnimation(AnimFolder:WaitForChild("MouseOn"))
local MouseOffAnim = Animator:LoadAnimation(AnimFolder:WaitForChild("MouseOff"))
local MouseOnIdle = Animator:LoadAnimation(AnimFolder:WaitForChild("MouseOnIdle"))
local SelectedAnim = Animator:LoadAnimation(AnimFolder:WaitForChild("Selected"))
local Tween_Service = game:GetService("TweenService")
local goal = {BackgroundTransparency = 1}
local goal2 = {BackgroundTransparency = 0}
local info = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0)
local tween1 = Tween_Service:Create(FadeFrame, info, goal2)
local tween2 = Tween_Service:Create(FadeFrame, info, goal)
local Currently_RunningAnim : AnimationTrack = IdleAnim
local CanRun = true
--//VARIABLES END//--
--//FUNCTIONS//--
IdleAnim:Play()
Context_Action_Service:BindAction(
StopMoving,
function() return Enum.ContextActionResult.Sink end,
false,
unpack(Enum.PlayerActions:GetEnumItems())
)
local function HandleMouseOn()
if not CanRun then return end
Currently_RunningAnim:Stop()
MouseOnAnim:Play()
Currently_RunningAnim = MouseOnAnim
task.wait(MouseOnAnim.Length)
MouseOnIdle:Play()
Currently_RunningAnim = MouseOnIdle
end
local function HandleMouseOff()
if not CanRun then return end
MouseOffAnim:Play()
Currently_RunningAnim:Stop()
Currently_RunningAnim = MouseOffAnim
task.wait(MouseOffAnim.Length)
IdleAnim:Play()
Currently_RunningAnim = IdleAnim
end
local function HandleSelect()
if not CanRun then return end
CanRun = false
SelectedAnim:Play()
Currently_RunningAnim:Stop()
task.wait(.7)
tween1:Play()
task.wait(1)
FadeFrame.Parent.Enabled = false
tween2:Play()
task.wait(1)
Context_Action_Service:UnbindAction("freezeMovement")
end
ImgButton.MouseEnter:Connect(HandleMouseOn)
ImgButton.MouseLeave:Connect(HandleMouseOff)
ImgButton.MouseButton1Click:Connect(HandleSelect)
--//FUNCTIONS END//--
end
return VPMS