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

Don’t set part0 to HRP, set it to torso or uppertorso, because uppertorso animates with the run, and that makes the gun move with the character animations, otherwise the arms move and the gun doesn’t because HRP can’t be animated

2 Likes

I believe it is because your gun hits the ground when you equip it.

Try making sure all the parts of the gun have CanCollide set to False.

It tells me "attempt to index nil with ‘Torso’ I’ve made sure I’m using R6.

It means that the thing the Torso is inside of doesn’t exist(according to the script)

I have the same issue, have you found a solution?

I have this problem: my tool is teleported back where it was left when it was unequipped. I have only tested from Roblox Studio.
However great tutorial

did you weld the gun to the arm or did you use a motor 6d, if you used a motor 6d it should work.

what is “Connect” suppose to mean? I understand I am suppose to figure it out but I cant get this right.

all of the parts are cancollide off

There’s an issue with installing the plugin. I get

Launch Task InstallPlugin requires valid -assetId

+1 This is a very helpful tutorial, but I have a few things to ask.

Would I have to animate the equipped and unequipped actions for my tool? I was fine with the default one, but now whenever I equip my tool the right arm doesn’t go up as if it was a normal tool.

Now, my tool is stuck in the torso, but I already made sure that the tool is unanchored, not welded, and each line of code is working. I think it may be the hot weather, but I can not figure out what is wrong. How would I position it to be on the right arm?

I wish the tutorial was a little more clear in how the tool is positioned.

fail

Here is the code, which is basically what is seen in the tutorial. (I hope)

Client
-- [[ Services ]] --
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

-- [[ Tool ]] --
local zapperTool = script.Parent

-- [[ Remotes ]] --
local remoteEvents = ReplicatedStorage:WaitForChild("RemoteEvents")
local ConnectMotor6D = remoteEvents:WaitForChild("ConnectMotor6D")
local DisconnectMotor6D = remoteEvents:WaitForChild("DisconnectMotor6D")

-- [[ Player ]] --
local localPlayer = Players.LocalPlayer
local localCharacter = localPlayer.Character or localPlayer.CharacterAdded:wait()
local localHumanoid = localCharacter:WaitForChild("Humanoid")
local mouse = localPlayer:GetMouse()

local toolGrip = localCharacter.Torso:WaitForChild("ToolGrip")
local bodyAttach = zapperTool:WaitForChild("BodyAttach")

-- [[ Animations ]] --
local zapperFire = zapperTool:WaitForChild("ZapperFire")
local zapperFireTrack = localHumanoid:LoadAnimation(zapperFire)

zapperTool.Equipped:Connect(function()	
	ConnectMotor6D:FireServer(bodyAttach)
	
	toolGrip.Part0 = localCharacter.Torso
	toolGrip.Part1 = bodyAttach
end)

zapperTool.Unequipped:Connect(function()
	DisconnectMotor6D:FireServer()
end)

-- Fires onZap to server and changes appearance of zapper
zapperTool.Activated:Connect(function()
	zapperFireTrack.Priority = Enum.AnimationPriority.Action
	zapperFireTrack.Looped = false
	zapperFireTrack:Play()
end)

Summary
-- [[ Services ]] --
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvents = ReplicatedStorage:WaitForChild("RemoteEvents")
local ConnectMotor6D = remoteEvents:WaitForChild("ConnectMotor6D")
local DisconnectMotor6D = remoteEvents:WaitForChild("DisconnectMotor6D")

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local motor6D = Instance.new("Motor6D")
		motor6D.Parent = character.Torso
		motor6D.Name = "ToolGrip"
	end)
end)

ConnectMotor6D.OnServerEvent:Connect(function(player,location)
	local character = player.Character or player.CharacterAdded:wait()
	character.Torso.ToolGrip.Part0 = character.Torso
	character.Torso.ToolGrip.Part1 = location
end)

DisconnectMotor6D.OnServerEvent:Connect(function(player)
	player.Character.Torso.ToolGrip.Part1 = nil
end)

Your reply doesn’t help the user at all. If you managed to do it then you may want to explain him how and maybe he could also help you debug.

Very nice tutorial, this will help a lot!

Hey, @Headstackk, great tutorial! I’ve been using ever since I first read the tutorial. The only issue I’ve found is when adding that Motor6D into the torso, you get this:


This aspect isn’t the issue necessarily but when do all the programming and adding the animations, I come across an issue where when I equip the tool, this happens:
To me, it’s awkward seeing a weapon come from behind you. My question is, do you know any way to fix this or make the problem less prevalent? Thanks for your time and the tutorial! :cowboy_hat_face:
-Queued

3 Likes

This is a great tutorial, now I know how to make animations. Thanks so much!
https://gyazo.com/a6214ae905715f0d892eb852fc937180

However how I can make the gun point at mouse like this


(reference to one of the examples you provided)

nvm I did it.

https://gyazo.com/6b6da081226b85c91a93d5b3aecc1c03

1 Like

That happened to me when I didnt parent the body attach to the gun model

1 Like

I think we said that, but there’s an easier way of adding a Motor6D on the character - just make it server sided, should work - works for me.

Here’s my code:

script.Parent.Equipped:Connect(function()
	local char = script.Parent.Parent
	local motor = Instance.new("Motor6D")
	motor.Parent=char.LowerTorso
	motor.Name = "BodyAttatch"
	motor.Part0 = char.LowerTorso
	motor.Part1 = script.Parent.BodyAttatch
end)

image

Edit: I don’t know if we need to remove it when unequip, It’s optional but yes, I recommend doing so.

4 Likes

I’m in full agreement this is the method that I personally prefer. This tutorial has made my game millions of time easier to develop.

2 Likes

How do I stop the arms and etc from moving when holding the gun. Because the idle animations are not overwritten even if the priority is to action or the highest.