How To "Easily" Make Tool Movement Animations

When I was trying to find solutions for this problem nothing was showing up so it took me a very long time to come up with a solution on my lonesome, mainly becuase I’m not a very good scripter. So I decide To make a tutorial of my own. Mind you I am VERY new to scripting so the script my be buggy.

I am open to critisism :grinning:.

local humanoid = nil
local character = nil
local player = nil
local humanoidrootPart = nil


script.Parent.Equipped:Connect(function()
	humanoid = script.Parent.Parent.Humanoid
	
	player = game.Players.LocalPlayer
	
	character = player.Character or player.CharacterAdded:Wait()
	
	forwardAnim = character:WaitForChild("Humanoid"):LoadAnimation(script:WaitForChild("ForwardAnim"))
	idleAnim = character:WaitForChild("Humanoid"):LoadAnimation(script:WaitForChild("IdleAnim"))
	
	humanoidrootPart = script.Parent.Parent.HumanoidRootPart
	
	idleAnim:Play()
	
	humanoid.Running:Connect(function(speed)
		if speed > 0.01 then
			forwardAnim:Play()
		else
			forwardAnim:Stop()
		end
	end)

	
	
	
end)

script.Parent.Unequipped:Connect(function()
	idleAnim:Stop()
	forwardAnim:Stop()
end)

put this in a local script in your tool and put you animations inside your script. :grinning:

4 Likes

This should be in #resources:community-resources as it does not have step-by-step instructions on how to achieve this.

1 Like

I’ve moved the topic to the correct location

Heres some advise for coding
use pascalcase(first letter of each word capitalised)
LikeThisForExample
on your variables.

and you overstrech your code
you should try to keep it readable and close together.

2 Likes

casing is completely optional and as you like and i see he likes camelcase

Camel case is usually used by roblox and luau functions
PascalCase is used usually for like user created things such as variables
it helps show the difference between your variables and roblox’s

also camel case has capitals after not just full lowercase thats clearly not camel case
(look at humanoidrootpart)

Do you have any videos, it’s better for visualization.

camelCase is used for that too, its just style choice. no need to suggest

I think you can remove all the = nil parts so it’d look like local humanoid

Uh, this is completely up to the programmer.

I was actually planning on making one.
I’ll link it after I make it.