Animation weirdly not loading

Good evening! Last night, I was working on animations for a raycast firearm I am working on. The aiming animation was working fine, however the fire animation wasen’t. When I woke up, I hopped ingame, and tested it. For some reason, which I can not and will not understand, the fire animation magically worked. I then added another, ‘resting’ animation, then my fire animation simply stopped working. I did some digging around, and apparentally the maximum amount of animations that can be loaded in a short period is 10, however I am by no means going past this limit.

Is anyone able to help?

local tool = script.Parent.Parent
local aimanim
local patrolanim
local fireanim
local cursor = game.Players.LocalPlayer:GetMouse()
local uis = game:GetService("UserInputService")
local atpatrolrest = false
local ammoloaded = 30

tool.Equipped:Connect(function(mouse)
	aimanim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Parent.Animations.AimAnim)
	patrolanim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Parent.Animations.PatrolRestAnim)
	fireanim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Parent.Animations.FireAnimation)

I made sure all animation IDs are correct, and it worked this morning without any edit, so that can’t be the issue.

Your resting animation’s priority level might be overriding your firing animation.

Make sure that your firing animation’s priority is higher than that of the resting animation. You can look up “Animation Priorities” if need be.

Yes, I thought that too, to my memory, they are both on the ‘Movement’ priority, and they haven’t been changed, so I don’t think that could be the issue. I’ll go ahead and double check. Give me some time.

I set the aiming animation to Idle, and now it’s caused a tool glitch where the right arm is held out. Find image attached below.

@cooldeath49

All Roblox animations use the Core priority, with some exceptions (Jump and toolnone) using Idle. Use a higher priority to fix this issue. Movement is recommended so that an Action animation (e.g. firing) can override a movement animation.

If that animation is Movement, not sure how toolnone is overriding it - shouldn’t be.

I set the aiming animation to idle, however that didn’t work. I just set the aiming animation to Movement, and set the fire animation to Action, however that isn’t working either now.

When I set the aiming animation to movement, yes, it overrid the toolnone, but firing still a negative.

You have to make a Motor6D between the tool and the body part connecting to it. When you select the tool, the motor6d is made. When you unselect it, the motor6d is destroyed.

Also, the “RequiresHandle” property in the Tool might be a problem. Uncheck that, it might help.

Why would I need a Motor6D? Could you explain some more?

:watermelon: Hiya!

Try using this code:

local tool = script.Parent.Parent

local cursor = game.Players.LocalPlayer:GetMouse()
local uis = game:GetService("UserInputService")

local atpatrolrest = false
local ammoloaded = 30

function animate()
local aimanim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Parent.Animations.AimAnim)
local patrolanim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Parent.Animations.PatrolRestAnim)
local fireanim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Parent.Animations.FireAnimation)
end

tool.Equipped:Connect(function(mouse)
animate()
end)

Gave it a try, didn’t work since the animations are defined in the function scope. Fixed it up by putting the variables above the function, and still didn’t work.

Try adding a game:GetService(¨RunService¨).Heartbeat:Wait(0.3) after each animation string.

Like this?

function animate()
	aimanim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Parent.Animations.AimAnim)
	game:GetService("RunService").Heartbeat:Wait(0.3)
	patrolanim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Parent.Animations.PatrolRestAnim)
	game:GetService("RunService").Heartbeat:Wait(0.3)
	fireanim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Parent.Animations.FireAnimation)
end

Tried it, still not working. :frowning:

Mhm. This is so we can make sure that the animations are loading properly, while making sure its smooth. A regular wait string can get a bit messy and mess up how smooth your code functions.

I’m going to attempt to move around the LoadAnimations, to see if it has something to do with cooldowns. 1 moment.

Here, I think this article should do justice.

Alright. This should work as many people mention the overriding that could be happening. If the wait statements dont work, please try extending the length just to see if we have a fix to the issue. We can always mess with the wait length later.

I moved them around, still seems like the resting animation and aiming animation still work, even though resting LoadAnimation was replaced with where the fire animation was loaded. It seems like something is broken with fire animation. I can’t find anything though

Use a print statement and mess around with it more. If it still doesnt work only for that animation, you should figure out issues with that specific animation.

I’ve set the animation priorities as follow:

Aiming - Movement
Resting - Movement
Fire - Action

Seeing from another post, action overrides movement. I’m not sure what’s happening.