Gun idle animation not working

So I have a localscript inside of a tool, the tool goes to the players backpack when they join the game.
This is what is inside of the localscript that is inside of the tool:

local Tool = nil
local animScript = nil
local animId = 6963606877

	Tool = script.Parent
	animScript = Tool.Parent:WaitForChild("Animate")
	local ToolNoneAnim = animScript:WaitForChild("toolnone"):WaitForChild("ToolNoneAnim")
	ToolNoneAnim.AnimationId = "rbxassetid://".. animId

	local ToolNoneAnim = animScript:WaitForChild("toolnone"):WaitForChild("ToolNoneAnim")
	ToolNoneAnim.AnimationId = ""

What I’m hoping to achieve with this is when the player equips the tool, it plays the idle animation for this tool, however nothing happens and I even checked the idle animation in the character that it should be changing and it is changing just nothing is happening to the player.
Any help would be greatly appreciated

Have you tried setting your animations to “Action” instead of “Core”?

It’s already set to action, I’ve tried setting it both as idle and action and neither work

You never seem to actually :Play() the animation when the tool is equipped. Also, make sure that the animation is looped.

You could just do this

local tool = script.Parent
local animId = 6963606877
local anim = nil

    local character = tool.Parent -- When the tool is equipped, it moves to the player's model.
    local humanoid = character:WaitForChild("Humanoid")
    local animation ="Animation")
    anim.AnimationId = "rbxassetid://".. animId

    anim = humanoid:LoadAnimation(animation)

    if anim then
        anim = nil 

Also, make sure that your animation is looped.

I thought setting the animation to the characters toolnone animation automatically plays it? And I’ve already tried making the animation play when the character equips the tool using an entirely difference script and that didn’t work, here’s that script.

local player = game.Players.LocalPlayer
local char = player.Character
local anim = script.Parent:WaitForChild("idleAnim")
local animLoad
local hum

    hum = char:WaitForChild("Humanoid")
    animLoad = hum:LoadAnimation(anim)
    anim.Looped = true


This did not work whatsoever, that’s why I decided to do it this way. And I’m pretty sure toolnone plays on its own using roblox’s scripts.

humaniod:LoadAnitimation is deprecated so careful!

Well, in that script you are using :WaitForChild() on something that has already loaded, in this case it is this line:

hum = char:WaitForChild("Humanoid")

Since the humanoid has already loaded into the game this will cause the script to yield infinitely and stop any further code from running. Instead, change it to

hum = char:FindFirstChild("Humanoid")

(If you use your previous code and change what I suggested it should work)

WaitForChild() Doesn’t yield when an object is already loaded.

1 Like

Oops my bad :grimacing: :sweat_smile:

1 Like