Animations not loading when the tool is given

I’ve been implementing animations to my gun for a few days and I encountered a problem: when the gun is given from replicated storage, all animations fail to load on a character (this problem does not appear in case of a gun being in starter pack). Is there a way to fix this problem?
here’s the script for better understanding

script.Parent.Equipped:Connect(function()
	humanoid = script.Parent.Parent.Humanoid
	player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
	char = script.Parent.Parent
	equipAnim = char:WaitForChild("Humanoid"):LoadAnimation(script:WaitForChild("EquipAnim"))
	idleAnim = char:WaitForChild("Humanoid"):LoadAnimation(script:WaitForChild("IdleAnim"))
	reloadAnim = char:WaitForChild("Humanoid"):LoadAnimation(script:WaitForChild("ReloadingAnim"))
	braceaimingAnim = char:WaitForChild("Humanoid"):LoadAnimation(script:WaitForChild("BraceAimingAnim"))
	aimingAnim = char:WaitForChild("Humanoid"):LoadAnimation(script:WaitForChild("AimingAnim"))
	braceshootingAnim = char:WaitForChild("Humanoid"):LoadAnimation(script:WaitForChild("BraceShootingAnim"))
	shootingAnim = char:WaitForChild("Humanoid"):LoadAnimation(script:WaitForChild("ShootingAnim"))
	rootPart = script.Parent.Parent.HumanoidRootPart
	mouse = player:GetMouse()
	equipped = true
	equipAnim:Play(transitionTime)
	idleAnim:Play(transitionTime)
	if reloadEvent == nil then
		reloadEvent = ReloadAnimEvent.OnClientEvent:Connect(function()
			reloadAnim:Play(transitionTime)
		end)
	end
end)
1 Like

Humanoid:LoadAnimation() is old and not supported
you should load animation through the Animator and not the humanoid

(how to check for animator,

local animator = humanoid:FindFirstChild("Animator") or Instance.new("Animator", humanoid)

animator:LoadAnimation(animation)

(there was a misspell, edited it to fix)

1 Like

Oouh babes the issue lies in how you’re referencing the animations when the gun is given from replicated storage, you need to ensure that the animations are properly replicated and accessible to the client

When the gun is in the starter pack, the animations load correctly because they are already present in the character’s hierarchy. However when the gun is given from replicated storage, the script is unable to find the animations, thus resulting in the animations failing to load! Hopefully I helped you! Xx

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.