Custom weapon idle animation

Hello everybody! I have a script which allows for a custom idle animation while holding a tool. Its quite simple…all you have to do is place the script inside the tool you want the animation for and change the animation ID inside the script to your liking. The only issue im having is getting the animation to stop playing when i move. The idle animation overrides all other animations so im stuck sliding around in my idle animation.

local tool = script.Parent
local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/Asset?ID=7413588577" --replace with id
local track
tool.Equipped:Connect(function()
	track = script.Parent.Parent.Humanoid:LoadAnimation(anim)
	track.Priority = Enum.AnimationPriority.Action
	track.Looped = true
	track:Play()
end)
tool.Unequipped:Connect(function()
	if track then
		track:Stop()
	end
end)
1 Like

There is a read-only property called “MoveDirection” in a humanoid
https://developer.roblox.com/en-us/api-reference/property/Humanoid/MoveDirection

You should check the magnitude property if it’s greater than 0 to check if the humanoid is moving or not

You can do what mathdotrandom said, or you could not animate the legs during the idle animation. The reason why you “slide around” is most likely because the animation of the legs moving overriding the movement animation

isn’t tool none animation more simpler? just change the tool none animation id.

You should change the animation priority to idle not Action. If it is action it will override all other movement and idle animations.

I also suggest you stop playing the default animation that already plays when you spawn your character.

I will try it out and get back to you. You mean the toolnone id in the animate script?

1 Like

The animation is set to idle. And how would i go about stopping the default animation?

Well thee are a number of ways you can do that. One way is to simply change the default animations of your game and set it to add yourself.
You can get all tracks that are playing by doing;
Animator:GetPlayingTracks()

You could create and add your own animate script and manually play all the animations. - That’s what I would do but it takes a bit more work.

You could change the animations IDs via script inside the character or fork the animation script and it’s IDs and then change the IDs by hand.

Using Animations | Roblox Creator Documentation

There is an article explaining in depth how you can do that.

im gonna take a look a look at that right now! thanks!

If you want the Animation to override the player holding tool animation, you should use Movement priority.

Idk if im stupid or something but i made my animation and put it in my gun, so when i stand still the idle animation works but the second i start walking the left hand starts wiggling really weirdly. is there a way to remove that?

You’re setting the animation priority to action, it needs to be set to idle