How to animate Tool Parts (Guns, Knifes etc.)

2022/12/13 Update: Can’t believe this thread is 3 years old, I have updated the majority content of this tutorial (including the code) and improved readability.

Hello everyone! I am Headstackk.

I have developed a Weapon Framework used in my game Weaponry. In this post, I will explain how to get started with animating tools, especially weapons on Roblox.

In most of the Roblox weapon frameworks (Excluding advanced shooter frameworks such as Phantom Forces), I observed that they usually only adapt simple animations, these animations does not include details such as detached magazine, moving bolt etc. In this tutorial, I’m going to show you how to animate those details.

Here are some example animations taken from Weaponry:

Let’s get started.

1: Create an animating Dummy:
Go to the “Avatar” tab, click “Rig Builder”, then create a rig that you want to animate on (R6/R15).

For this demonstration, I will be animating in R6 with the “Block Rig”.

2: Creating a root part for the tool

Your weapon and dummy needs a Rig in order to be animatable. Don’t worry. This sounds a lot easier than it looks.

Create a new part and name it “BodyAttach”. This part is essentially the root of the tool. You can place it anywhere within the tool. I personally put in near the trigger of the weapon, or where the character’s arm holds at.

Group EVERYTHING including the BodyAttach under a model.
And place the model UNDER the animating dummy.

3: Welding
Welding means sticking the parts inside the tool together.

Before we proceed, you have to install this plugin: Constraint Editor - Roblox
It is a must have plugin when it comes to welding.

How to use the plugin:

1: Select the BodyAttach (the root part created in the previous step)
2: HOLD CONTROL and CLICK select parts that needs to be welded. (demonstrated in the video below)
3: For parts that needs to be ANIMATED (such as weapon magazine, bolt etc.), click New Motor6D. For EVERY remaining parts, click New Weld.

For parts that needs to be ANIMATED:

For EVERY other remaining parts:

Your BodyAttach should have these welds and Motor6Ds after this step:
They connect every part of your tool to the BodyAttach, and the BodyAttach holds them all together.
Make sure EVERY SINGLE PART inside the model has EITHER a Weld / Motor6D!!!

4: Connecting the dummy to the tool:

Here you have to choose WHERE do you want the tool to stick with the character.

Left / Right Arm: If you wish the tool to move along with either one of the arms, choose Left / Right Arm. This behaves similar to a typical Roblox tool.

NOTE: The tool moves ACCORDINGLY with the arm if you choose this method. Which means whenever the right arm MOVES in an animation, the tool WILL move accordingly.

Weld to Right Arm:


Torso: If you wish the tool to NOT be constrained by the arms, aka being able to move freely when animating, choose Torso.

However, if you choose this method, the tool will NOT move when you animate the right arm. Which means the character is no longer “holding” the tool. This method is highly suggested for people who animates in Blender. since Blender constraints can solve this problem.

Weld to Torso:

Benefits of welding to Torso: (Click here to see)

The advantage of welding to torso is that you can animate the gun freely instead of having it stick to the Right Arm all the time.
Examples:

LMG reloads:
Image from Gyazo

Reloading with right arm

And more! You can even animate melee / knife tricks animation with this, without the knife being stick to the Right Arm all the time.

After you have decided on which character part to weld on, Click this “+” icon next to the dummy part that you have decided on. (Torso / Arm / Others)

image

Then search for Motor6D and insert one.

image

After inserting the Motor6D, make sure everything under your tool is UNANCHORED!!

Then, connect the Motor6D’s:

  • Part0 to the decieded part (Torso / Right Arm / Others).
  • Part1 to the BodyAttach.

After connecting, your tool should be sticking to the dummy.

If some of the parts of your tool is missing after this step, it can either be:

  • Some parts of your tool were anchored
  • Some parts of your tool were not rigged (refer to the previous step)

6: You can start animating!
Open the Roblox Animation Editor, then you can start animating!
The rig can also be exported and animate in Blender.

7: Essential part: In game

You will find this not working in game if you just put it as a typical tool, there are few essential steps to do before you put it into the game and have the tool run as expected.

Firstly, make sure it has RequireHandles OFF as a tool.

Then, some scripting has to be done.

While animating, the tool was welded to the character’s torso (or the part that you have deiced on), the same rule applies in game!

Firstly, when the player’s character was being added, grant them an initial Motor6D such that it can be used to connect the player and the tool.

Then when a player equips the tool, you have to connect the Motor6D with the Player’s Character’s Part so the tool does not fall.

So how do we approach this?

We can use ChildAdded to keep track of when a tool is being equipped. When the tool was being equipped, connect the Motor6D with the character.

-- Server Script
game.Players.PlayerAdded:Connect(function(plr)			
	plr.CharacterAdded:Connect(function(char)		
		local M6D = Instance.new("Motor6D", char.Torso) -- or the part that you have decieded
		M6D.Name = "ToolGrip"

		char.ChildAdded:Connect(function(child)
			if child:IsA("Tool") and child:FindFirstChild("BodyAttach") then
				M6D.Part1 = child.BodyAttach
			end
		end)
	end)
end)

You can also connect the Motor6D on the client as well such that when a tool is equipped, the client does not have to wait for the server to connect it and the Motor6D will be immediately connected on the client’s view.

-- LocalScript, variables are NOT defined.
char.ChildAdded:Connect(function(child)
	if child:IsA("Tool") and child:FindFirstChild("BodyAttach") then
		char.Torso.ToolGrip.Part1 = child.BodyAttach
	end
end)

You might also want to play the tool animation when the tool is being equipped.

-- LocalScript under the tool:
-- Animation playing
local anim = Instance.new("Animation", script.Parent)
anim.AnimationId = "" -- id here

local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local load = char:WaitForChild("Humanoid"):LoadAnimation(anim)
script.Parent.Equipped:Connect(function()
	anim:Play()		
end)

script.Parent.Unequipped:Connect(function()
	anim:Stop()
end)

-- Connecting Motor6D locally

local anim = Instance.new("Animation", script.Parent)
anim.AnimationId = "" -- id here

local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local load = char:WaitForChild("Humanoid"):LoadAnimation(anim)

script.Parent.Equipped:Connect(function()
	anim:Play()		
end)

script.Parent.Unequipped:Connect(function()
	anim:Stop()
end)

The End

And that concludes on how to animate a tool and its parts. Feel free to reply and raise questions if you have any.

A like :+1: on this post and a visit on my game Weaponry will be greatly appreciated! Thank you.

2103 Likes

Thanks! This is very useful and it’s explained very well, I might start animating guns soon!

115 Likes

Very well taught tutorial, i might even consider moving back to animating again! :smile:

53 Likes

Will this worked with lightsaber as well?

40 Likes

Any model i think, all you’ll have to do is follow the steps in this guide but do it for what you desire to animate.

23 Likes

Yeah but the script kinda make me confused it not worked in studio when I test it.

23 Likes

The script is for reference only! It’s a part of my code and you have to set up variables and instances by yourself.

43 Likes

I can’t select the gun while animating with the default ROBLOX anim editor. Any help?

19 Likes

Really good tutorial! Although, i just have a question. Does this work with R15 too?

15 Likes

It should work with R15, just use UpperTorso instead of Torso.

35 Likes

It says that ToolGrip is not a valid member of part, still doesn’t work even though if I add a :WaitForChild. Do you know what to do? I can send you my full script that I added variables to, if necessary.

10 Likes

I fixed the issue, but now it won’t even play the animation when I try to equip it.

Here’s what it looks like in the game: https://gyazo.com/8fa67950b50682c508bd362cd6b7b6f7

Here’s what it looks like in animator: https://gyazo.com/e4e54bbc8793978e47ab69be2ba7d5f9

What it looks like on a regular tool: https://gyazo.com/1df5cde578ac41cf89e4e152cbaa7562 (just to prove that the animation actually works)

If anyone could add me on Discord to help me resolve this minor issue, please add me: stick pepega#1603

10 Likes

Never mind, I figured it out. It seems like you can only play the animation through a local script.

11 Likes

Thanks for this, I’ll definitely try this out, however I only know the simplest of scripting so I might have problems with that part of it.

10 Likes

You wanna know what would be REALLY nice? A video tutorial, following this step by step. My small brain hurts when I try to follow this as how it is. I think it’d help others (including myself).

My brain hurts. Send help. No, I did not manage to get what I wanted (to animate my tools with motor6Ds.)

48 Likes

Please if you don’t mind is there any possible way that you can provide a very basic example model/file of this?
You see I learn faster by looking at models.

13 Likes

Help, it doesn’t seem to work for me, I want to make a Idle animation for my gun. I followed every instruction you did, but it didn’t quite work for me so I made it so it waits for the motor 6d to be made. It seemed to work but now this happens :
s

and this is what it’s supposed to look like
s

It’s my first time animating a Gun. I also put the priority to Idle. I have no idea what’s happening. What I saw is: Normally when you spawn, your character has a idle animation it kinda breathes. But when I equip the gun , it stops the idle animation. I don’t know what may be the problem, someone please help. Thank you

15 Likes

You need to set your priority higher, ‘Idle’ is overridden by the tool’s default holding animation. It’s safe to put custom idle animations as ‘action’ priority, it will still be overridden by any ‘actions’ you play next.

30 Likes

Thank you, I solved it today already. I was very confused why this was happening.

8 Likes

I’ve been using that weld plugin ever since I originally saw this post. Super helpful man. Grateful to have had this in my time of stupidity.

13 Likes