Hello, I’m trying to load an animation for use in a combat game.
I use Humanoid.Animator:LoadAnimation() and it almost always works. Sometimes, however, the animation loads (or doesn’t) and any markers added to it don’t load.
It returns an error, saying: Failed to load animation://AnimationIdHere
How can i fix this?
It’s probably because the animations didn’t load yet, I’d recommend using :WaitForChild() when describing variables so that way, the script will wait for the animations to load before proceeding.
For example:
local Tool = script.Parent
local Animation = Tool:WaitForChild("SwingAnim")
local Debounce = false
Tool.Activated:Connect(function()
if not Debounce then
Debounce = true
local SwingAnim = Tool.Parent.Humanoid:WaitForChild("Animator"):LoadAnimation(Animation)
SwingAnim:Play()
task.wait(1)
Debounce = false
end
end)
The error occurs when i try to preload the animation using the ContentProvider service. i list any animation in the game and i add it to a table for it to load, so im not sure its the LoadAnimation thats the problem…
either way the animation still plays when the markers dont work, so that basically makes that certain
You should probably include a script to make it more easier to solve your issue.
for _, v in pairs(game:GetService("ReplicatedStorage"):GetDescendants()) do
if v:IsA("Animation") or v:IsA("MeshPart") or v:IsA("Texture") or v:IsA("Decal") then
table.insert(AssetsToLoad,v)
end
end
warn("Assets Loading")
ContentProvider:PreloadAsync(AssetsToLoad)
warn("Assets loaded on client")
And here’s how I play the animation. Done on server via a RemoteEvent
local AttackAnimation = Humanoid.Animator:LoadAnimation(Assets.AttackAnimation)
AttackAnimation:Play()
-- AttackAnimation:AdjustSpeed(0.925)
Maybe the issue is that your pretty much also adding Meshes, Decals, and other stuff in the “for _, v in pairs()” loop, it’s probably selecting something rather than the animations. Maybe if you tell the script what it should be selecting then it could work possibly.
Well your also downloading it on the client… When you use it on the server… Meaning the server hasn’t downloaded the assets you loaded on the client As I understand it In the roblox Documentation which another issue on its own.
I also always gotta ask you own the animation & the game is owned by you, right?. Not by a group etc. Whoever owns the game also has to own the animation and this could be a common reason why its failing to load - becuse it just can’t.
So are you saying that I preload the assets in order by type?
Game and animations are owned by me
I think so, although I’d recommend POG’s solution.
So am I able to use ContentProvider on the server as well to achieve this?
I would yes. Or atleast try it for the animations
Alright, although i will say i can’t actively test if it will work. thanks for your help anyways
Problem happened again after i tried to fix everything…
I also included the AssetFetchFailed event to try and reload anything that didn’t reload.
what’s weird is that this didn’t return an error.