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:
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)
Then search for Motor6D and insert one.
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 on this post and a visit on my game Weaponry will be greatly appreciated! Thank you.