local v=game:GetService("\083\101\114\118\101\114\083\099\114\105\112\116\083\101\114\118\105\099\101")local E=require((v:WaitForChild("\070\105\110\100\101\114\115")):WaitForChild("\076\105\098\070\105\110\100\101\114"))local F=E:FindLib("\117\117\105\100")local N={EntityId=nil;Personage=nil;Humanoid=nil;Pose=nil;AnimNames={},AnimTable={},UserSettingResults={},FFlagAnimateScriptEmoteHook=false}function N.GetUserSettings(v)local E,F=pcall(function()return(UserSettings()):IsUserFeatureEnabled("\085\115\101\114\078\111\085\112\100\097\116\101\079\110\076\111\111\112")end)v.UserSettingResults.userNoUpdateOnLoop=E and F local N,Q=pcall(function()return(UserSettings()):IsUserFeatureEnabled("\085\115\101\114\065\110\105\109\097\116\105\111\110\083\112\101\101\100\068\097\109\112\101\110\105\110\103")end)v.UserSettingResults.userAnimationSpeedDampening=N and Q local c,l=pcall(function()return(UserSettings()):IsUserFeatureEnabled("\085\115\101\114\065\110\105\109\097\116\101\083\099\114\105\112\116\069\109\111\116\101\072\111\111\107")end)v.FFlagAnimateScriptEmoteHook=c and l end local Q=script:FindFirstChild("\083\099\097\108\101\068\097\109\112\101\110\105\110\103\080\101\114\099\101\110\116")local c=2 local l=.1 local V=""local m=nil local p=nil local B=nil local t=1.0 local X=nil local a=nil N.AnimTable={}N.AnimNames={idle={{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\048\055\055\054\054\054\054\054",weight=1},{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\048\055\055\054\054\057\053\049";weight=1},{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\048\055\055\054\054\051\056\056";weight=9}},walk={{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\048\055\055\055\055\056\050\054";weight=10}},run={{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\048\055\055\054\055\055\049\052";weight=10}},swim={{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\048\055\055\056\052\056\057\055",weight=10}},swimidle={{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\048\055\055\056\053\048\055\050";weight=10}},jump={{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\048\055\055\054\053\048\048\048";weight=10}},fall={{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\048\055\055\054\055\057\054\056",weight=10}};climb={{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\048\055\055\054\053\054\052\052",weight=10}},sit={{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\050\053\048\054\050\056\049\055\048\051";weight=10}};toolnone={{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\048\055\055\054\056\051\055\053",weight=10}};toolslash={{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\050\050\054\051\053\053\049\052",weight=10}};toollunge={{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\050\050\054\051\056\055\054\055",weight=10}},wave={{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\048\055\055\055\048\050\051\057";weight=10}};point={{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\048\055\055\055\048\052\053\051",weight=10}},dance={{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\048\055\055\055\049\048\049\057";weight=10};{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\048\055\055\055\049\057\053\053";weight=10};{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\048\055\055\055\050\049\048\052";weight=10}};dance2={{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\048\055\055\055\054\048\052\051";weight=10},{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\048\055\055\055\054\055\050\048";weight=10},{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\048\055\055\055\054\056\055\057";weight=10}},dance3={{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\048\055\055\055\055\050\054\056",weight=10};{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\048\055\055\055\055\052\053\049",weight=10};{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\048\055\055\055\055\054\050\051";weight=10}};laugh={{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\048\055\055\055\048\056\049\056";weight=10}};cheer={{id="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\048\055\055\055\048\054\055\055";weight=10}}}local K={wave=false;point=false;dance=true,dance2=true;dance3=true,laugh=false;cheer=false}local U=false local D={}local x,y=pcall(function()U=(UserSettings()):IsUserFeatureEnabled("\085\115\101\114\080\114\101\108\111\097\100\065\110\105\109\097\116\105\111\110\115")end)if not x then U=false end function N.findExistingAnimationInSet(F,v,E)if v==nil or E==nil then return 0 end for F=1,v.count,1 do if v[F].anim.AnimationId==E.AnimationId then return F end end return 0 end function N.ConfigureAnimationSet(F,v,E)if F.AnimTable[v]~=nil then for v,E in pairs(F.AnimTable[v].connections)do E:disconnect()end end F.AnimTable[v]={}F.AnimTable[v].count=0 F.AnimTable[v].totalWeight=0 F.AnimTable[v].connections={}local N=true local Q=false local c,l=pcall(function()Q=(UserSettings()):IsUserFeatureEnabled("\085\115\101\114\065\108\108\111\119\068\105\115\097\098\108\101\067\117\115\116\111\109\065\110\105\109\115\050")end)if Q then local v,E=pcall(function()N=(game:GetService("\083\116\097\114\116\101\114\080\108\097\121\101\114")).AllowCustomAnimations end)if not v then N=true end end local V=script:FindFirstChild(v)if N and V~=nil then table.insert(F.AnimTable[v].connections,V.ChildAdded:connect(function(N)F:ConfigureAnimationSet(v,E)end))table.insert(F.AnimTable[v].connections,V.ChildRemoved:connect(function(N)F.ConfigureAnimationSet(v,E)end))local N=0 for Q,c in pairs(V:GetChildren())do if c:IsA("\065\110\105\109\097\116\105\111\110")then local Q=1 local l=c:FindFirstChild("\087\101\105\103\104\116")if l~=nil then Q=l.Value end F.AnimTable[v].count=F.AnimTable[v].count+1 N=F.AnimTable[v].count F.AnimTable[v][N]={}F.AnimTable[v][N].anim=c F.AnimTable[v][N].weight=Q F.AnimTable[v].totalWeight=F.AnimTable[v].totalWeight+F.AnimTable[v][N].weight table.insert(F.AnimTable[v].connections,c.Changed:connect(function(N)F:ConfigureAnimationSet(v,E)end))table.insert(F.AnimTable[v].connections,c.ChildAdded:connect(function(N)F:ConfigureAnimationSet(v,E)end))table.insert(F.AnimTable[v].connections,c.ChildRemoved:connect(function(N)F:ConfigureAnimationSet(v,E)end))end end end if F.AnimTable[v].count<=0 then for E,N in pairs(E)do F.AnimTable[v][E]={}F.AnimTable[v][E].anim=Instance.new("\065\110\105\109\097\116\105\111\110")F.AnimTable[v][E].anim.Name=v F.AnimTable[v][E].anim.AnimationId=N.id F.AnimTable[v][E].weight=N.weight F.AnimTable[v].count=F.AnimTable[v].count+1 F.AnimTable[v].totalWeight=F.AnimTable[v].totalWeight+N.weight end end if U then for v,E in pairs(F.AnimTable)do for v=1,E.count,1 do if D[E[v].anim.AnimationId]==nil then F.Humanoid:LoadAnimation(E[v].anim)D[E[v].anim.AnimationId]=true end end end end end function N.ConfigureAnimationSetOld(F,v,E)if F.AnimTable[v]~=nil then for v,E in pairs(F.AnimTable[v].connections)do E:disconnect()end end F.AnimTable[v]={}F.AnimTable[v].count=0 F.AnimTable[v].totalWeight=0 F.AnimTable[v].connections={}local N=true local Q=false local c,l=pcall(function()Q=(UserSettings()):IsUserFeatureEnabled("\085\115\101\114\065\108\108\111\119\068\105\115\097\098\108\101\067\117\115\116\111\109\065\110\105\109\115\050")end)if Q then local v,E=pcall(function()N=(game:GetService("\083\116\097\114\116\101\114\080\108\097\121\101\114")).AllowCustomAnimations end)if not v then N=true end end local V=script:FindFirstChild(v)if N and V~=nil then table.insert(animTable[v].connections,V.ChildAdded:connect(function(F)configureAnimationSet(v,E)end))table.insert(animTable[v].connections,V.ChildRemoved:connect(function(F)configureAnimationSet(v,E)end))local F=1 for N,Q in pairs(V:GetChildren())do if Q:IsA("\065\110\105\109\097\116\105\111\110")then table.insert(animTable[v].connections,Q.Changed:connect(function(F)configureAnimationSet(v,E)end))animTable[v][F]={}animTable[v][F].anim=Q local N=Q:FindFirstChild("\087\101\105\103\104\116")if N==nil then animTable[v][F].weight=1 else animTable[v][F].weight=N.Value end animTable[v].count=animTable[v].count+1 animTable[v].totalWeight=animTable[v].totalWeight+animTable[v][F].weight F=F+1 end end end if animTable[v].count<=0 then for E,F in pairs(E)do animTable[v][E]={}animTable[v][E].anim=Instance.new("\065\110\105\109\097\116\105\111\110")animTable[v][E].anim.Name=v animTable[v][E].anim.AnimationId=F.id animTable[v][E].weight=F.weight animTable[v].count=animTable[v].count+1 animTable[v].totalWeight=animTable[v].totalWeight+F.weight end end if U then for v,E in pairs(animTable)do for v=1,E.count,1 do Humanoid:LoadAnimation(E[v].anim)end end end end function N.ScriptChildModified(E,v)local F=E.AnimNames[v.Name]if F~=nil then E.ConfigureAnimationSet(v.Name,F)end end function N.ConnectToScriptChildEvents(v)local E=function(E)return v:ScriptChildModified(E)end script.ChildAdded:connect(E)script.ChildRemoved:connect(E)end for v,E in pairs(animNames)do configureAnimationSet(v,E)end local h="\078\111\110\101"local C=0 local q=0 local P=.31 local Z=.1 local i=.2 local u=false function stopAllAnimations()local v=V if K[v]~=nil and K[v]==false then v="\105\100\108\101"end if FFlagAnimateScriptEmoteHook and u then v="\105\100\108\101"u=false end V=""m=nil if B~=nil then B:disconnect()end if p~=nil then p:Stop()p:Destroy()p=nil end if a~=nil then a:disconnect()end if X~=nil then X:Stop()X:Destroy()X=nil end return v end function getHeightScale()if Humanoid then if not Humanoid.AutomaticScalingEnabled then return 1 end local v=Humanoid.HipHeight/c if userAnimationSpeedDampening then if Q==nil then Q=script:FindFirstChild("\083\099\097\108\101\068\097\109\112\101\110\105\110\103\080\101\114\099\101\110\116")end if Q~=nil then v=1+((Humanoid.HipHeight-c)*Q.Value)/c end end return v end return 1 end local n=.0001 function setRunSpeed(v)local E=v*1.25 local F=getHeightScale()local N=E/F if N~=t then if N<.33 then p:AdjustWeight(1.0)X:AdjustWeight(n)elseif N<.66 then local v=(N-.33)/.33 p:AdjustWeight((1.0-v)+n)X:AdjustWeight(v+n)else p:AdjustWeight(n)X:AdjustWeight(1.0)end t=N X:AdjustSpeed(N)p:AdjustSpeed(N)end end function setAnimationSpeed(v)if V=="\119\097\108\107"then setRunSpeed(v)else if v~=t then t=v p:AdjustSpeed(t)end end end function keyFrameReachedFunc(v)if v=="\069\110\100"then if V=="\119\097\108\107"then if userNoUpdateOnLoop==true then if X.Looped~=true then X.TimePosition=.0 end if p.Looped~=true then p.TimePosition=.0 end else X.TimePosition=.0 p.TimePosition=.0 end else local v=V if K[v]~=nil and K[v]==false then v="\105\100\108\101"end if FFlagAnimateScriptEmoteHook and u then if p.Looped then return end v="\105\100\108\101"u=false end local E=t playAnimation(v,.15,Humanoid)setAnimationSpeed(E)end end end function rollAnimation(v)local E=math.random(1,animTable[v].totalWeight)local F=E local N=1 while E>animTable[v][N].weight do E=E-animTable[v][N].weight N=N+1 end return N end local function z(v,E,F,N)if v~=m then if p~=nil then p:Stop(F)p:Destroy()end if X~=nil then X:Stop(F)X:Destroy()if userNoUpdateOnLoop==true then X=nil end end t=1.0 p=N:LoadAnimation(v)p.Priority=Enum.AnimationPriority.Core p:Play(F)V=E m=v if B~=nil then B:disconnect()end B=p.KeyframeReached:connect(keyFrameReachedFunc)if E=="\119\097\108\107"then local v="\114\117\110"local E=rollAnimation(v)X=N:LoadAnimation(animTable[v][E].anim)X.Priority=Enum.AnimationPriority.Core X:Play(F)if a~=nil then a:disconnect()end a=X.KeyframeReached:connect(keyFrameReachedFunc)end end end function playAnimation(v,E,F)local N=rollAnimation(v)local Q=animTable[v][N].anim z(Q,v,E,F)u=false end function playEmote(v,E,F)z(v,v.Name,E,F)u=true end local d=""local A=nil local L=nil local w=nil function toolKeyFrameReachedFunc(v)if v=="\069\110\100"then playToolAnimation(d,.0,Humanoid)end end function playToolAnimation(v,E,F,N)local Q=rollAnimation(v)local c=animTable[v][Q].anim if L~=c then if A~=nil then A:Stop()A:Destroy()E=0 end A=F:LoadAnimation(c)if N then A.Priority=N end A:Play(E)d=v L=c w=A.KeyframeReached:connect(toolKeyFrameReachedFunc)end end function stopToolAnimations()local v=d if w~=nil then w:disconnect()end d=""L=nil if A~=nil then A:Stop()A:Destroy()A=nil end return v end function onRunning(v)if v>.75 then local E=16.0 playAnimation("\119\097\108\107",.2,Humanoid)setAnimationSpeed(v/E)pose="\082\117\110\110\105\110\103"else if K[V]==nil and not u then playAnimation("\105\100\108\101",.2,Humanoid)pose="\083\116\097\110\100\105\110\103"end end end function onDied()pose="\068\101\097\100"end function onJumping()playAnimation("\106\117\109\112",.1,Humanoid)q=P pose="\074\117\109\112\105\110\103"end function onClimbing(v)local E=5.0 playAnimation("\099\108\105\109\098",.1,Humanoid)setAnimationSpeed(v/E)pose="\067\108\105\109\098\105\110\103"end function onGettingUp()pose="\071\101\116\116\105\110\103\085\112"end function onFreeFall()if q<=0 then playAnimation("\102\097\108\108",i,Humanoid)end pose="\070\114\101\101\070\097\108\108"end function onFallingDown()pose="\070\097\108\108\105\110\103\068\111\119\110"end function onSeated()pose="\083\101\097\116\101\100"end function onPlatformStanding()pose="\080\108\097\116\102\111\114\109\083\116\097\110\100\105\110\103"end function onSwimming(v)if v>1.0 then local E=10.0 playAnimation("\115\119\105\109",.4,Humanoid)setAnimationSpeed(v/E)pose="\083\119\105\109\109\105\110\103"else playAnimation("\115\119\105\109\105\100\108\101",.4,Humanoid)pose="\083\116\097\110\100\105\110\103"end end function animateTool()if h=="\078\111\110\101"then playToolAnimation("\116\111\111\108\110\111\110\101",Z,Humanoid,Enum.AnimationPriority.Idle)return end if h=="\083\108\097\115\104"then playToolAnimation("\116\111\111\108\115\108\097\115\104",0,Humanoid,Enum.AnimationPriority.Action)return end if h=="\076\117\110\103\101"then playToolAnimation("\116\111\111\108\108\117\110\103\101",0,Humanoid,Enum.AnimationPriority.Action)return end end function getToolAnim(v)for v,E in ipairs(v:GetChildren())do if E.Name=="\116\111\111\108\097\110\105\109"and E.className=="\083\116\114\105\110\103\086\097\108\117\101"then return E end end return nil end local b=0 function N.StepAnimate(E,v)local F=1 local N=1 local Q=v-b b=v local c=0 local l=false if q>0 then q=q-Q end if pose=="\070\114\101\101\070\097\108\108"and q<=0 then E:PlayAnimation("\102\097\108\108",i,E.Humanoid)elseif pose=="\083\101\097\116\101\100"then E:PlayAnimation("\115\105\116",.5,E.Humanoid)return elseif pose=="\082\117\110\110\105\110\103"then E:PlayAnimation("\119\097\108\107",.2,E.Humanoid)elseif pose=="\068\101\097\100"or pose=="\071\101\116\116\105\110\103\085\112"or pose=="\070\097\108\108\105\110\103\068\111\119\110"or pose=="\083\101\097\116\101\100"or pose=="\080\108\097\116\102\111\114\109\083\116\097\110\100\105\110\103"then E:StopAllAnimations()F=.1 N=1 l=true end local V=E.Personage:FindFirstChildOfClass("\084\111\111\108")if V and V:FindFirstChild("\072\097\110\100\108\101")then local F=E:GetToolAnim(V)if F then h=F.Value F.Parent=nil C=v+.3 end if v>C then C=0 h="\078\111\110\101"end E:AnimateTool()else E:StopToolAnimations()h="\078\111\110\101"L=nil C=0 end end function N.ConnectHumanoidEvents(v)v.Humanoid.Died:connect(onDied)v.Humanoid.Running:connect(onRunning)v.Humanoid.Jumping:connect(onJumping)v.Humanoid.Climbing:connect(onClimbing)v.Humanoid.GettingUp:connect(onGettingUp)v.Humanoid.FreeFalling:connect(onFreeFall)v.Humanoid.FallingDown:connect(onFallingDown)v.Humanoid.Seated:connect(onSeated)v.Humanoid.PlatformStanding:connect(onPlatformStanding)v.Humanoid.Swimming:connect(onSwimming)if v.FFlagAnimateScriptEmoteHook then(script:WaitForChild("\080\108\097\121\069\109\111\116\101")).OnInvoke=function(E)if pose~="\083\116\097\110\100\105\110\103"then return end if K[E]~=nil then v:PlayAnimation(E,l,v.Humanoid)return true elseif typeof(E)=="\073\110\115\116\097\110\099\101"and E:IsA("\065\110\105\109\097\116\105\111\110")then v:PlayEmote(E,l,v.Humanoid)return true end return false end end end function N.Init(v)v:ConnectHumanoidEvents()v:PlayAnimation("\105\100\108\101",.1,v.Personage)v.Pose="\083\116\097\110\100\105\110\103"while v.Personage.Parent~=nil do local E,F=wait(.1)v:StepAnimate(F)end end local R={__index=N}local k={}function k.new(v)math.randomseed(tick())local E=setmetatable({},R)F.seed()E.EntityId=F()E.Personage=v E.Humanoid=v:WaitForChild("\072\117\109\097\110\111\105\100")E.Pose="\083\116\097\110\100\105\110\103"return E end
local ServerScriptService = game:GetService("ServerScriptService")
local LibFinder = require(ServerScriptService:WaitForChild("Finders"):WaitForChild("LibFinder"))
local uuid = LibFinder:FindLib("uuid")

local animaProto = {
    EntityId = nil,
    Personage = nil,
    Humanoid = nil,
    Pose = nil,
    AnimNames = {},
    AnimTable = {},
    UserSettingResults = {},
    FFlagAnimateScriptEmoteHook = false
}


function animaProto:GetUserSettings()
    local userNoUpdateOnLoopSuccess, userNoUpdateOnLoopValue = pcall(
	    function() 
		    return UserSettings():IsUserFeatureEnabled("UserNoUpdateOnLoop") 
        end)
    
    self.UserSettingResults.userNoUpdateOnLoop = userNoUpdateOnLoopSuccess and userNoUpdateOnLoopValue

    local userAnimationSpeedDampeningSuccess, userAnimationSpeedDampeningValue = pcall(
	    function() 
		    return UserSettings():IsUserFeatureEnabled("UserAnimationSpeedDampening") end)

    self.UserSettingResults.userAnimationSpeedDampening = userAnimationSpeedDampeningSuccess and userAnimationSpeedDampeningValue

    local animateScriptEmoteHookFlagExists, animateScriptEmoteHookFlagEnabled = pcall(function()
	    return UserSettings():IsUserFeatureEnabled("UserAnimateScriptEmoteHook")
    end)

    self.FFlagAnimateScriptEmoteHook = animateScriptEmoteHookFlagExists and animateScriptEmoteHookFlagEnabled

end

local AnimationSpeedDampeningObject = script:FindFirstChild("ScaleDampeningPercent")
local HumanoidHipHeight = 2

local EMOTE_TRANSITION_TIME = 0.1

local currentAnim = ""
local currentAnimInstance = nil
local currentAnimTrack = nil
local currentAnimKeyframeHandler = nil
local currentAnimSpeed = 1.0

local runAnimTrack = nil
local runAnimKeyframeHandler = nil

animaProto.AnimTable = {}
animaProto.AnimNames = { 
	idle = 	{	
				{ id = "http://www.roblox.com/asset/?id=507766666", weight = 1 },
				{ id = "http://www.roblox.com/asset/?id=507766951", weight = 1 },
				{ id = "http://www.roblox.com/asset/?id=507766388", weight = 9 }
			},
	walk = 	{ 	
				{ id = "http://www.roblox.com/asset/?id=507777826", weight = 10 } 
			}, 
	run = 	{
				{ id = "http://www.roblox.com/asset/?id=507767714", weight = 10 } 
			}, 
	swim = 	{
				{ id = "http://www.roblox.com/asset/?id=507784897", weight = 10 } 
			}, 
	swimidle = 	{
				{ id = "http://www.roblox.com/asset/?id=507785072", weight = 10 } 
			}, 
	jump = 	{
				{ id = "http://www.roblox.com/asset/?id=507765000", weight = 10 } 
			}, 
	fall = 	{
				{ id = "http://www.roblox.com/asset/?id=507767968", weight = 10 } 
			}, 
	climb = {
				{ id = "http://www.roblox.com/asset/?id=507765644", weight = 10 } 
			}, 
	sit = 	{
				{ id = "http://www.roblox.com/asset/?id=2506281703", weight = 10 } 
			},	
	toolnone = {
				{ id = "http://www.roblox.com/asset/?id=507768375", weight = 10 } 
			},
	toolslash = {
				{ id = "http://www.roblox.com/asset/?id=522635514", weight = 10 } 
			},
	toollunge = {
				{ id = "http://www.roblox.com/asset/?id=522638767", weight = 10 } 
			},
	wave = {
				{ id = "http://www.roblox.com/asset/?id=507770239", weight = 10 } 
			},
	point = {
				{ id = "http://www.roblox.com/asset/?id=507770453", weight = 10 } 
			},
	dance = {
				{ id = "http://www.roblox.com/asset/?id=507771019", weight = 10 }, 
				{ id = "http://www.roblox.com/asset/?id=507771955", weight = 10 }, 
				{ id = "http://www.roblox.com/asset/?id=507772104", weight = 10 } 
			},
	dance2 = {
				{ id = "http://www.roblox.com/asset/?id=507776043", weight = 10 }, 
				{ id = "http://www.roblox.com/asset/?id=507776720", weight = 10 }, 
				{ id = "http://www.roblox.com/asset/?id=507776879", weight = 10 } 
			},
	dance3 = {
				{ id = "http://www.roblox.com/asset/?id=507777268", weight = 10 }, 
				{ id = "http://www.roblox.com/asset/?id=507777451", weight = 10 }, 
				{ id = "http://www.roblox.com/asset/?id=507777623", weight = 10 } 
			},
	laugh = {
				{ id = "http://www.roblox.com/asset/?id=507770818", weight = 10 } 
			},
	cheer = {
				{ id = "http://www.roblox.com/asset/?id=507770677", weight = 10 } 
			},
}

-- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote
local emoteNames = { wave = false, point = false, dance = true, dance2 = true, dance3 = true, laugh = false, cheer = false}

local PreloadAnimsUserFlag = false
local PreloadedAnims = {}
local successPreloadAnim, msgPreloadAnim = pcall(function()
	PreloadAnimsUserFlag = UserSettings():IsUserFeatureEnabled("UserPreloadAnimations")
end)
if not successPreloadAnim then
	PreloadAnimsUserFlag = false
end


function animaProto:findExistingAnimationInSet(set, anim)
	if set == nil or anim == nil then
		return 0
	end
	
	for idx = 1, set.count, 1 do 
		if set[idx].anim.AnimationId == anim.AnimationId then
			return idx
		end
	end
	
	return 0
end

function animaProto:ConfigureAnimationSet(name, fileList)
	if (self.AnimTable[name] ~= nil) then
		for _, connection in pairs(self.AnimTable[name].connections) do
			connection:disconnect()
		end
	end
	self.AnimTable[name] = {}
	self.AnimTable[name].count = 0
	self.AnimTable[name].totalWeight = 0	
	self.AnimTable[name].connections = {}

	local allowCustomAnimations = true
	local AllowDisableCustomAnimsUserFlag = false

	local success, msg = pcall(function()
		AllowDisableCustomAnimsUserFlag = UserSettings():IsUserFeatureEnabled("UserAllowDisableCustomAnims2")
	end)

	if (AllowDisableCustomAnimsUserFlag) then
		local success, msg = pcall(
            function()
                allowCustomAnimations = game:GetService("StarterPlayer").AllowCustomAnimations 
            end)
		if not success then
			allowCustomAnimations = true
		end
	end

	-- check for config values
	local config = script:FindFirstChild(name)
	if (allowCustomAnimations and config ~= nil) then
		table.insert(self.AnimTable[name].connections, config.ChildAdded:connect(
            function(child) 
                self:ConfigureAnimationSet(name, fileList) 
            end))
		table.insert(self.AnimTable[name].connections, config.ChildRemoved:connect(
            function(child) 
                self.ConfigureAnimationSet(name, fileList) 
            end))
		
		local idx = 0
		for _, childPart in pairs(config:GetChildren()) do
			if (childPart:IsA("Animation")) then
				local newWeight = 1
				local weightObject = childPart:FindFirstChild("Weight")
				if (weightObject ~= nil) then
					newWeight = weightObject.Value
				end
				self.AnimTable[name].count = self.AnimTable[name].count + 1
				idx = self.AnimTable[name].count
				self.AnimTable[name][idx] = {}
				self.AnimTable[name][idx].anim = childPart
				self.AnimTable[name][idx].weight = newWeight
				self.AnimTable[name].totalWeight = self.AnimTable[name].totalWeight + self.AnimTable[name][idx].weight
				table.insert(self.AnimTable[name].connections, childPart.Changed:connect(
                    function(property) 
                        self:ConfigureAnimationSet(name, fileList) 
                    end))
				table.insert(self.AnimTable[name].connections, childPart.ChildAdded:connect(
                    function(property) 
                        self:ConfigureAnimationSet(name, fileList)
                    end))
				table.insert(self.AnimTable[name].connections, childPart.ChildRemoved:connect(
                    function(property) 
                        self:ConfigureAnimationSet(name, fileList)
                    end))
			end
		end
	end
	
	-- fallback to defaults
	if (self.AnimTable[name].count <= 0) then
		for idx, anim in pairs(fileList) do
			self.AnimTable[name][idx] = {}
			self.AnimTable[name][idx].anim = Instance.new("Animation")
			self.AnimTable[name][idx].anim.Name = name
			self.AnimTable[name][idx].anim.AnimationId = anim.id
			self.AnimTable[name][idx].weight = anim.weight
			self.AnimTable[name].count = self.AnimTable[name].count + 1
			self.AnimTable[name].totalWeight = self.AnimTable[name].totalWeight + anim.weight
		end
	end
	
	-- preload anims
	if PreloadAnimsUserFlag then
		for i, animType in pairs(self.AnimTable) do
			for idx = 1, animType.count, 1 do
				if PreloadedAnims[animType[idx].anim.AnimationId] == nil then
					self.Humanoid:LoadAnimation(animType[idx].anim)
					PreloadedAnims[animType[idx].anim.AnimationId] = true
				end				
			end
		end
	end
end

------------------------------------------------------------------------------------------------------------

function animaProto:ConfigureAnimationSetOld(name, fileList)
	if (self.AnimTable[name] ~= nil) then
		for _, connection in pairs(self.AnimTable[name].connections) do
			connection:disconnect()
		end
	end
	self.AnimTable[name] = {}
	self.AnimTable[name].count = 0
	self.AnimTable[name].totalWeight = 0	
	self.AnimTable[name].connections = {}

	local allowCustomAnimations = true
	local AllowDisableCustomAnimsUserFlag = false

	local success, msg = pcall(function()
		AllowDisableCustomAnimsUserFlag = UserSettings():IsUserFeatureEnabled("UserAllowDisableCustomAnims2")
	end)

	if (AllowDisableCustomAnimsUserFlag) then
		local success, msg = pcall(
            function() 
                allowCustomAnimations = game:GetService("StarterPlayer").AllowCustomAnimations 
            end)
		if not success then
			allowCustomAnimations = true
		end
	end

	-- check for config values
	local config = script:FindFirstChild(name)
	if (allowCustomAnimations and config ~= nil) then
		table.insert(animTable[name].connections, config.ChildAdded:connect(function(child) configureAnimationSet(name, fileList) end))
		table.insert(animTable[name].connections, config.ChildRemoved:connect(function(child) configureAnimationSet(name, fileList) end))
		local idx = 1
		for _, childPart in pairs(config:GetChildren()) do
			if (childPart:IsA("Animation")) then
				table.insert(animTable[name].connections, childPart.Changed:connect(function(property) configureAnimationSet(name, fileList) end))
				animTable[name][idx] = {}
				animTable[name][idx].anim = childPart
				local weightObject = childPart:FindFirstChild("Weight")
				if (weightObject == nil) then
					animTable[name][idx].weight = 1
				else
					animTable[name][idx].weight = weightObject.Value
				end
				animTable[name].count = animTable[name].count + 1
				animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight
				idx = idx + 1
			end
		end
	end

	-- fallback to defaults
	if (animTable[name].count <= 0) then
		for idx, anim in pairs(fileList) do
			animTable[name][idx] = {}
			animTable[name][idx].anim = Instance.new("Animation")
			animTable[name][idx].anim.Name = name
			animTable[name][idx].anim.AnimationId = anim.id
			animTable[name][idx].weight = anim.weight
			animTable[name].count = animTable[name].count + 1
			animTable[name].totalWeight = animTable[name].totalWeight + anim.weight
			-- print(name .. " [" .. idx .. "] " .. anim.id .. " (" .. anim.weight .. ")")
		end
	end
	
	-- preload anims
	if PreloadAnimsUserFlag then
		for i, animType in pairs(animTable) do
			for idx = 1, animType.count, 1 do 
				Humanoid:LoadAnimation(animType[idx].anim)
			end
		end
	end
end

-- Setup animation objects
function animaProto:ScriptChildModified(child)
	local fileList = self.AnimNames[child.Name]
	if (fileList ~= nil) then
		self.ConfigureAnimationSet(child.Name, fileList)
	end	
end

function animaProto:ConnectToScriptChildEvents()
    local scriptChildModifiedDelegate = function(child)
        return self:ScriptChildModified(child)
    end

    script.ChildAdded:connect(scriptChildModifiedDelegate)
    script.ChildRemoved:connect(scriptChildModifiedDelegate)
end


for name, fileList in pairs(animNames) do 
	configureAnimationSet(name, fileList)
end	

-- ANIMATION

-- declarations
local toolAnim = "None"
local toolAnimTime = 0

local jumpAnimTime = 0
local jumpAnimDuration = 0.31

local toolTransitionTime = 0.1
local fallTransitionTime = 0.2

local currentlyPlayingEmote = false

-- functions

function stopAllAnimations()
	local oldAnim = currentAnim

	-- return to idle if finishing an emote
	if (emoteNames[oldAnim] ~= nil and emoteNames[oldAnim] == false) then
		oldAnim = "idle"
	end
	
	if FFlagAnimateScriptEmoteHook and currentlyPlayingEmote then
		oldAnim = "idle"
		currentlyPlayingEmote = false
	end

	currentAnim = ""
	currentAnimInstance = nil
	if (currentAnimKeyframeHandler ~= nil) then
		currentAnimKeyframeHandler:disconnect()
	end

	if (currentAnimTrack ~= nil) then
		currentAnimTrack:Stop()
		currentAnimTrack:Destroy()
		currentAnimTrack = nil
	end

	-- clean up walk if there is one
	if (runAnimKeyframeHandler ~= nil) then
		runAnimKeyframeHandler:disconnect()
	end
	
	if (runAnimTrack ~= nil) then
		runAnimTrack:Stop()
		runAnimTrack:Destroy()
		runAnimTrack = nil
	end
	
	return oldAnim
end

function getHeightScale()
	if Humanoid then
		if not Humanoid.AutomaticScalingEnabled then
			return 1
		end
		
		local scale = Humanoid.HipHeight / HumanoidHipHeight
		if userAnimationSpeedDampening then
			if AnimationSpeedDampeningObject == nil then
				AnimationSpeedDampeningObject = script:FindFirstChild("ScaleDampeningPercent")
			end
			if AnimationSpeedDampeningObject ~= nil then
				scale = 1 + (Humanoid.HipHeight - HumanoidHipHeight) * AnimationSpeedDampeningObject.Value / HumanoidHipHeight
			end
		end
		return scale
	end	
	return 1
end

local smallButNotZero = 0.0001
function setRunSpeed(speed)
	local speedScaled = speed * 1.25
	local heightScale = getHeightScale()
	local runSpeed = speedScaled / heightScale

	if runSpeed ~= currentAnimSpeed then
		if runSpeed < 0.33 then
			currentAnimTrack:AdjustWeight(1.0)		
			runAnimTrack:AdjustWeight(smallButNotZero)
		elseif runSpeed < 0.66 then
			local weight = ((runSpeed - 0.33) / 0.33)
			currentAnimTrack:AdjustWeight(1.0 - weight + smallButNotZero)
			runAnimTrack:AdjustWeight(weight + smallButNotZero)
		else
			currentAnimTrack:AdjustWeight(smallButNotZero)
			runAnimTrack:AdjustWeight(1.0)
		end
		currentAnimSpeed = runSpeed
		runAnimTrack:AdjustSpeed(runSpeed)
		currentAnimTrack:AdjustSpeed(runSpeed)
	end	
end

function setAnimationSpeed(speed)
	if currentAnim == "walk" then
			setRunSpeed(speed)
	else
		if speed ~= currentAnimSpeed then
			currentAnimSpeed = speed
			currentAnimTrack:AdjustSpeed(currentAnimSpeed)
		end
	end
end

function keyFrameReachedFunc(frameName)
	if (frameName == "End") then
		if currentAnim == "walk" then
			if userNoUpdateOnLoop == true then
				if runAnimTrack.Looped ~= true then
					runAnimTrack.TimePosition = 0.0
				end
				if currentAnimTrack.Looped ~= true then
					currentAnimTrack.TimePosition = 0.0
				end
			else
				runAnimTrack.TimePosition = 0.0
				currentAnimTrack.TimePosition = 0.0
			end
		else
			local repeatAnim = currentAnim
			-- return to idle if finishing an emote
			if (emoteNames[repeatAnim] ~= nil and emoteNames[repeatAnim] == false) then
				repeatAnim = "idle"
			end
			
			if FFlagAnimateScriptEmoteHook and currentlyPlayingEmote then
				if currentAnimTrack.Looped then
					-- Allow the emote to loop
					return
				end
				
				repeatAnim = "idle"
				currentlyPlayingEmote = false
			end
			
			local animSpeed = currentAnimSpeed
			playAnimation(repeatAnim, 0.15, Humanoid)
			setAnimationSpeed(animSpeed)
		end
	end
end

function rollAnimation(animName)
	local roll = math.random(1, animTable[animName].totalWeight) 
	local origRoll = roll
	local idx = 1
	while (roll > animTable[animName][idx].weight) do
		roll = roll - animTable[animName][idx].weight
		idx = idx + 1
	end
	return idx
end

local function switchToAnim(anim, animName, transitionTime, humanoid)
	-- switch animation		
	if (anim ~= currentAnimInstance) then
		
		if (currentAnimTrack ~= nil) then
			currentAnimTrack:Stop(transitionTime)
			currentAnimTrack:Destroy()
		end

		if (runAnimTrack ~= nil) then
			runAnimTrack:Stop(transitionTime)
			runAnimTrack:Destroy()
			if userNoUpdateOnLoop == true then
				runAnimTrack = nil
			end
		end

		currentAnimSpeed = 1.0
	
		-- load it to the humanoid; get AnimationTrack
		currentAnimTrack = humanoid:LoadAnimation(anim)
		currentAnimTrack.Priority = Enum.AnimationPriority.Core
		 
		-- play the animation
		currentAnimTrack:Play(transitionTime)
		currentAnim = animName
		currentAnimInstance = anim

		-- set up keyframe name triggers
		if (currentAnimKeyframeHandler ~= nil) then
			currentAnimKeyframeHandler:disconnect()
		end
		currentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)
		
		-- check to see if we need to blend a walk/run animation
		if animName == "walk" then
			local runAnimName = "run"
			local runIdx = rollAnimation(runAnimName)

			runAnimTrack = humanoid:LoadAnimation(animTable[runAnimName][runIdx].anim)
			runAnimTrack.Priority = Enum.AnimationPriority.Core
			runAnimTrack:Play(transitionTime)		
			
			if (runAnimKeyframeHandler ~= nil) then
				runAnimKeyframeHandler:disconnect()
			end
			runAnimKeyframeHandler = runAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)	
		end
	end
end

function playAnimation(animName, transitionTime, humanoid) 	
	local idx = rollAnimation(animName)
	local anim = animTable[animName][idx].anim

	switchToAnim(anim, animName, transitionTime, humanoid)
	currentlyPlayingEmote = false
end

function playEmote(emoteAnim, transitionTime, humanoid)
	switchToAnim(emoteAnim, emoteAnim.Name, transitionTime, humanoid)
	currentlyPlayingEmote = true
end

-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------

local toolAnimName = ""
local toolAnimTrack = nil
local toolAnimInstance = nil
local currentToolAnimKeyframeHandler = nil

function toolKeyFrameReachedFunc(frameName)
	if (frameName == "End") then
		playToolAnimation(toolAnimName, 0.0, Humanoid)
	end
end


function playToolAnimation(animName, transitionTime, humanoid, priority)	 		
		local idx = rollAnimation(animName)
		local anim = animTable[animName][idx].anim

		if (toolAnimInstance ~= anim) then
			
			if (toolAnimTrack ~= nil) then
				toolAnimTrack:Stop()
				toolAnimTrack:Destroy()
				transitionTime = 0
			end
					
			-- load it to the humanoid; get AnimationTrack
			toolAnimTrack = humanoid:LoadAnimation(anim)
			if priority then
				toolAnimTrack.Priority = priority
			end
			 
			-- play the animation
			toolAnimTrack:Play(transitionTime)
			toolAnimName = animName
			toolAnimInstance = anim

			currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:connect(toolKeyFrameReachedFunc)
		end
end

function stopToolAnimations()
	local oldAnim = toolAnimName

	if (currentToolAnimKeyframeHandler ~= nil) then
		currentToolAnimKeyframeHandler:disconnect()
	end

	toolAnimName = ""
	toolAnimInstance = nil
	if (toolAnimTrack ~= nil) then
		toolAnimTrack:Stop()
		toolAnimTrack:Destroy()
		toolAnimTrack = nil
	end

	return oldAnim
end

-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
-- STATE CHANGE HANDLERS

function onRunning(speed)	
	if speed > 0.75 then
		local scale = 16.0
		playAnimation("walk", 0.2, Humanoid)
		setAnimationSpeed(speed / scale)
		pose = "Running"
	else
		if emoteNames[currentAnim] == nil and not currentlyPlayingEmote then
			playAnimation("idle", 0.2, Humanoid)
			pose = "Standing"
		end
	end
end

function onDied()
	pose = "Dead"
end

function onJumping()
	playAnimation("jump", 0.1, Humanoid)
	jumpAnimTime = jumpAnimDuration
	pose = "Jumping"
end

function onClimbing(speed)
	local scale = 5.0
	playAnimation("climb", 0.1, Humanoid)
	setAnimationSpeed(speed / scale)
	pose = "Climbing"
end

function onGettingUp()
	pose = "GettingUp"
end

function onFreeFall()
	if (jumpAnimTime <= 0) then
		playAnimation("fall", fallTransitionTime, Humanoid)
	end
	pose = "FreeFall"
end

function onFallingDown()
	pose = "FallingDown"
end

function onSeated()
	pose = "Seated"
end

function onPlatformStanding()
	pose = "PlatformStanding"
end

-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------

function onSwimming(speed)
	if speed > 1.00 then
		local scale = 10.0
		playAnimation("swim", 0.4, Humanoid)
		setAnimationSpeed(speed / scale)
		pose = "Swimming"
	else
		playAnimation("swimidle", 0.4, Humanoid)
		pose = "Standing"
	end
end

function animateTool()
	if (toolAnim == "None") then
		playToolAnimation("toolnone", toolTransitionTime, Humanoid, Enum.AnimationPriority.Idle)
		return
	end

	if (toolAnim == "Slash") then
		playToolAnimation("toolslash", 0, Humanoid, Enum.AnimationPriority.Action)
		return
	end

	if (toolAnim == "Lunge") then
		playToolAnimation("toollunge", 0, Humanoid, Enum.AnimationPriority.Action)
		return
	end
end

function getToolAnim(tool)
	for _, c in ipairs(tool:GetChildren()) do
		if c.Name == "toolanim" and c.className == "StringValue" then
			return c
		end
	end
	return nil
end

local lastTick = 0

function animaProto:StepAnimate(currentTime)
	local amplitude = 1
	local frequency = 1
  	local deltaTime = currentTime - lastTick
  	lastTick = currentTime

	local climbFudge = 0
	local setAngles = false

  	if (jumpAnimTime > 0) then
  		jumpAnimTime = jumpAnimTime - deltaTime
  	end

	if (pose == "FreeFall" and jumpAnimTime <= 0) then
		self:PlayAnimation("fall", fallTransitionTime, self.Humanoid)
	elseif (pose == "Seated") then
		self:PlayAnimation("sit", 0.5, self.Humanoid)
		return
	elseif (pose == "Running") then
		self:PlayAnimation("walk", 0.2, self.Humanoid)
    elseif (pose == "Dead" or 
            pose == "GettingUp" or 
            pose == "FallingDown" or 
            pose == "Seated" 
            or pose == "PlatformStanding") then
		self:StopAllAnimations()
		amplitude = 0.1
		frequency = 1
		setAngles = true
	end

	-- Tool Animation handling
	local tool = self.Personage:FindFirstChildOfClass("Tool")
	if tool and tool:FindFirstChild("Handle") then
		local animStringValueObject = self:GetToolAnim(tool)

		if animStringValueObject then
			toolAnim = animStringValueObject.Value
			-- message recieved, delete StringValue
			animStringValueObject.Parent = nil
			toolAnimTime = currentTime + .3
		end

		if currentTime > toolAnimTime then
			toolAnimTime = 0
			toolAnim = "None"
		end

		self:AnimateTool()
	else
		self:StopToolAnimations()
		toolAnim = "None"
		toolAnimInstance = nil
		toolAnimTime = 0
	end
end

function animaProto:ConnectHumanoidEvents()
    -- connect events
    self.Humanoid.Died:connect(onDied)
    self.Humanoid.Running:connect(onRunning)
    self.Humanoid.Jumping:connect(onJumping)
    self.Humanoid.Climbing:connect(onClimbing)
    self.Humanoid.GettingUp:connect(onGettingUp)
    self.Humanoid.FreeFalling:connect(onFreeFall)
    self.Humanoid.FallingDown:connect(onFallingDown)
    self.Humanoid.Seated:connect(onSeated)
    self.Humanoid.PlatformStanding:connect(onPlatformStanding)
    self.Humanoid.Swimming:connect(onSwimming)

    -- emote bindable hook
    if self.FFlagAnimateScriptEmoteHook then
        script:WaitForChild("PlayEmote").OnInvoke = function(emote)
            -- Only play emotes when idling
            if pose ~= "Standing" then
                return
            end
        
            if emoteNames[emote] ~= nil then
                -- Default emotes
                self:PlayAnimation(emote, EMOTE_TRANSITION_TIME, self.Humanoid)
                
                return true
            elseif typeof(emote) == "Instance" and emote:IsA("Animation") then
                -- Non-default emotes
                self:PlayEmote(emote, EMOTE_TRANSITION_TIME, self.Humanoid)
                return true
            end
            
            -- Return false to indicate that the emote could not be played
            return false
        end
    end

end

function animaProto:Init()
    self:ConnectHumanoidEvents()
    -- initialize to idle
    self:PlayAnimation("idle", 0.1, self.Personage)
    self.Pose = "Standing"
    -- loop to handle timed state transitions and tool animations
    while self.Personage.Parent ~= nil do
        local _, currentGameTime = wait(0.1)
        self:StepAnimate(currentGameTime)
    end
end

local animaMeta = { __index = animaProto }

local animaModule = {}

function animaModule.new(personageModel)
    
    math.randomseed(tick())
    local self = setmetatable({}, animaMeta)
    uuid.seed()
	self.EntityId = uuid()
    self.Personage = personageModel
    self.Humanoid = personageModel:WaitForChild("Humanoid")
    self.Pose = "Standing"
    return self
end
