BetterAnimate works like original Animate, but have more functionality
Introduction
As you know, when a player’s character spawns, Roblox creates an inside character script called “Animate”. This script contains information on how characters’s animations should work.
But roblox’s animate script logic and code looking is kinda bad (really bad).
Thats why I decided to rewrite everything
Why BetterAnimate is better?
R15 and R6 Support
Script automaticly determines which animations should be used for the character by checking Humanoid.RigType
Play custom tool animation
How to use custom tool animation:
local TransitionTime = 0.1
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://507768375"
local MyAnimator = BetterAnimate.New(Character)
MyAnimator:PlayToolAnimation(Animation, TransitionTime)
P.S Animation Instance will NOT be deleted
Disable Toolnone animation
To disable Toolnone animation (default animtaion when player equip tool), you need to:
Tool:SetAttribute("NoToolNone", true)
OR
Tool:AddTag("NoToolNone")
P.S: You can change Attribute and Tag name that need to check in Settings
Tool speed glitch fix
When you equip tool while emoting your сenter of character mass changes and let to move really fast while jumping (example), with this Animate script it no longer possible
Thanks to @treebee63
Optimized
BetterAnimate using custom timer logic with only 3 event connections:
Humanoid.StateChanged,
Character.ChildAdded,
Character.ChildRemoved
Inverse animations
To enable this you must set in Settings of BetterAnimate Enabled_Inverse = true
local MyAnimator = BetterAnimate.New(Character, {
Enabled_Inverse = true
})
-- OR
MyAnimator.Settings.Enabled_Inverse = true
Class_Inverse = { -- Determines what classes have this feature
Walk = true,
Run = true,
Swim = true,
Climb = true,
},
InverseOn = { -- Determines in which direction the inversion will work
BackwardRight = true,
BackwardLeft = true,
Backward = true,
Down = true, -- For climb
},
Update animations in real time
How to use:
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://507768375"
local TestMyAnimations = {
Idle = {
Idle1 = {ID = 1132473842, Weight = 1000},
{ID = 1132477671},
},
Toolnone = {
Toolnone1 = {Instance = Animation}
},
Run = { Run1 = {ID = 1132494274, Weight = 10} },
Walk = { Walk1 = {ID = 1132510133} },
Swim = { Swim1 = {ID = 1132500520} },
Swimidle = { Swimidle1 = {ID = 1132506407} },
Jump = { Jump1 = {ID = 1132489853} },
Fall = { Fall1 = {ID = 1132469004} },
Climb = { Climb1 = {ID = 1132461372} },
}
local ResetClass = true -- Means that the current class animations will be deleted
--[[
** NOTE **
if ResetClass = false it will add animations,
and if found animation with similar index (For example Fall1),
it will be replaced with new one
]]--
local MyAnimator = BetterAnimate.New(Character)
MyAnimator:UpdateAnimations(TestMyAnimations, ResetClass)
Signals
BetterAnimate have 4 Signals:
local BetterAniamte = require(PATH_TO_MODULE)
local MyAnimator = BetterAnimate.New(Character)
-- Fires on new state (Running, Falling, etc...)
MyAnimator.Signal_NewState:Connect(function(State: string) end)
-- Fires on new animation (Except tool animation)
MyAnimator.Signal_NewAnimation:Connect(function(AnimationClass: string, AnimationName: string, AnimationTable) end)
-- Fires on new **(String not Vector3)** moving direction
MyAnimator.Signal_NewDirection:Connect(function(Direction: string, Vector3_Direction: Vector3) end)
-- Fires on animation keyframe reached (Including tool animation)
MyAnimator.Signal_KeyframeReached:Connect(function(Keyframe: string) end)
Debug
BetterAnimate has a built-in debug that can be activated at any time to check the status
local Enable = true -- or false
local MyAnimator = BetterAnimate.New(Character)
MyAnimator:EnableDebug(Enable)
How to setup
local BetterAnimate = require(--Path_To_BetterAnimate--)
local InitSettings = {} -- You can change it later in MyAnimator.Settings
local MyAnimator = BetterAnimate.New(Character, InitSettings)
MyAnimator:Start()
Q&A
How to get & play avatar animations?
local LocalPlayer = game:GetService("Players").LocalPlayer
local BetterAnimate = require(PATH_TO_MODULE)
local AvatarAnimations = BetterAnimate.GetAvatarAnimationsByUserID(LocalPlayer.UserId)
local MyAnimator = BetterAnimate.New(Character)
MyAnimator:UpdateAnimations(AvatarAnimations, true)