Loading a whole animation set when equipping a tool

hi there,
I’m trying to create some code that changes all of the animations of a player when they equip a tool.

I already have code that changes the idle animation of a player when they hold it out, and the walk animations do work since I didn’t save keyframes for those body parts, but ideally the script would be able to load animations for running, jumping, swinging, ect. with the weapon all in one script.

the code I already have:

tool.Equipped:Connect(function()
	weldEvent:FireServer(bodyAttach,false)
    track = script.Parent.Parent.Humanoid:LoadAnimation(anim)
    track.Priority = Enum.AnimationPriority.Idle
    track.Looped = true
    track:Play()
end)
tool.Unequipped:Connect(function()
    if track then
		weldEvent:FireServer(bodyAttach,true)
        track:Stop()
    end
end)

its pretty ubiquitous. I’m just not entirely certain how to expand from it to load different animations for different player actions, since ive never worked with animations and I could not find any posts addressing how to do this.

im sorry if there are already resources out there on this: I looked far and wide and could not find any. and assistance at all would be greatly appreciated!

Well, you would have to go into all the players animations and change each individual one, while the sword is equipped.

what does that involve? is there some way to detect when, say, the run animation should be playing? or the jump?

Yes

Humanoid.Died:connect(onDied)

Humanoid.Running:connect(onRunning)

Humanoid.Jumping:connect(onJumping)

Humanoid.Climbing:connect(onClimbing)

Humanoid.GettingUp:connect(onGettingUp)

Humanoid.FreeFalling:connect(onFreeFall)

Humanoid.FallingDown:connect(onFallingDown)

Humanoid.Seated:connect(onSeated)

Humanoid.PlatformStanding:connect(onPlatformStanding)

Humanoid.Swimming:connect(onSwimming)
3 Likes

wow! this is perfect! thank you so much. i know this was probably kind of a stupid question, so thank you for spelling it out for me :slight_smile:
where did you get this list? is it in the API somewhere and i just missed it?

1 Like

Oh yes it’s in the humanoid api
https://developer.roblox.com/en-us/api-reference/class/Humanoid

1 Like

ohhhh, of course. thank you again so much. was so lost on this lel

1 Like