I’ve spent hours scratching my head at why my animations weren’t playing when I run loadedAnimation:Play().
It turns out, Animations do weird stuff if the animation playing it is in a global function.
I had a separate script:
[spoiler][code]local animations = {}
local loadedAnimations = {}
for _,v in pairs(game.ReplicatedStorage.Animations:GetChildren()) do
loadedAnimations[v.Name] = game.Players.LocalPlayer.Character:WaitForChild(“Humanoid”):LoadAnimation(v)
end
function _G.AddAnimation(anim, tween, weight, speed)
if animations[anim] then
animations[anim]:Stop(0)
end
local animation = loadedAnimations[anim]
animations[anim] = animation
animation:Play(tween, weight, speed)
end
function _G.RemoveAnimation(anim, tween)
local i = 1
for k,v in pairs(animations) do
if k == anim or anim == “All” then
v:Stop(tween)
coroutine.resume(coroutine.create(function() – Just for extra stability.
wait()
animations[k] = nil
end))
if anim ~= “All” then break end
end
end
end[/code][/spoiler]
And when I run _G.LoadAnimation() in a separate script, it doesn’t play.
However, if I don’t make the functions global, and add the functions to each of my LocalScripts, it will all work perfectly fine.