So I have a local script called AnimationHandler that obviously handles the animations. And the problem is when a player just spawned, it takes a few seconds to load all the animations into the humanoid and thats really annoying for some players. I tried removing the repeat until
, but then it just doesn’t load the animations
repeat task.wait()
for i, v in pairs(Tool.Animations:GetDescendants()) do
if v:IsA("Animation") and v.Name == "AttackRightShieldless" then
AttackRightShieldless = animator:LoadAnimation(v)
table.insert(allAnims, AttackRightShieldless)
table.insert(possibleAttackAnimations, AttackRightShieldless)
AttackRightShieldless:SetAttribute("Direction", "Right")
elseif v:IsA("Animation") and v.Name == "AttackLeftShieldless" then
AttackLeftShieldless = animator:LoadAnimation(v)
table.insert(allAnims, AttackLeftShieldless)
table.insert(possibleAttackAnimations, AttackLeftShieldless)
AttackLeftShieldless:SetAttribute("Direction", "Left")
elseif v:IsA("Animation") and v.Name == "AttackOverheadShieldless" then
AttackOverheadShieldless = animator:LoadAnimation(v)
table.insert(allAnims, AttackOverheadShieldless)
table.insert(possibleAttackAnimations, AttackOverheadShieldless)
AttackOverheadShieldless:SetAttribute("Direction", "Up")
elseif v:IsA("Animation") and v.Name == "AttackStabShieldless" then
AttackStabShieldless = animator:LoadAnimation(v)
table.insert(allAnims, AttackStabShieldless)
table.insert(possibleAttackAnimations, AttackStabShieldless)
AttackStabShieldless:SetAttribute("Direction", "Bottom")
elseif v:IsA("Animation") and v.Name == "Equip" then
Equip = animator:LoadAnimation(v)
table.insert(allAnims, Equip)
elseif v:IsA("Animation") and v.Name == "Block" then
Block = animator:LoadAnimation(v)
table.insert(allAnims, Block)
elseif v:IsA("Animation") and v.Name == "Idle" then
Idle = animator:LoadAnimation(v)
table.insert(allAnims, Idle)
end
end
until workspace:IsAncestorOf(character)
I guess there should be a different method to handle the animations loading, but I have no idea of how would I make it