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

Thank you! I will really need it. Although I would recommend an animator to do this work if you are making a big group game.

That’s the problem for me.

I turned “RequiresHandle” off and it still creates that RightGrip weld!
Can you help?
image
image
(i made the motor in RightArm for it to be easier for me.)
image
(it also breaks.)

NEVERMIND! I fixed it! Sorry for bothering!

is there a way or as method for r15 rigs to comply with this method? or not because I tried and it works but in a weird rotation

Hello, so I’m having a weird problem with this method, when your character resets or dies the script just crashes and doesn’t work anymore:
I tried using your script but its still not working :confused:

--[[ MAIN VARIABLES ]]--
local torsoPart = "UpperTorso"

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()

while char.Parent == nil do
	char.AncestryChanged:wait()
end

local idleAnim = char:WaitForChild("Humanoid"):LoadAnimation(script:WaitForChild("Idle"))
local shootAnim = char:WaitForChild("Humanoid"):LoadAnimation(script:WaitForChild("Activated"))

local tool = script.Parent

local toolGrip = char:WaitForChild(torsoPart):WaitForChild("ToolGrip")
local bodyAttach = tool:WaitForChild("BodyAttach")

local debounce = false

--<< MAIN FUNCTIONS >>--
local suffixes = {'','K','M','B','T','qd','Qn','sx','Sp','O','N','de','Ud','DD','tdD','qdD','QnD','sxD','SpD','OcD','NvD','Vgn','UVg','DVg','TVg','qtV','QnV','SeV','SPG','OVG','NVG','TGN','UTG','DTG','tsTG','qtTG','QnTG','ssTG','SpTG','OcTG','NoAG','UnAG','DuAG','TeAG','QdAG','QnAG','SxAG','SpAG','OcAG','NvAG','CT'}
local function format(val)
	for i=1, #suffixes do
		if tonumber(val) < 10^(i*3) then
			return math.floor(val/((10^((i-1)*3))/100))/(100)..suffixes[i]
		end
	end
end

local function fire(...)
	game.ReplicatedStorage.Books.BookAnim.ConnectM6D:FireServer(...)
end

local function ShowPoints()
	
	local Strength = script.Parent.Folder.Strength
	
	local random = math.random(1,1000)
	local xnew = random/1000
	local new = game.ReplicatedStorage.ShowPoints:Clone()
	new.Parent = plr.PlayerGui.PopUp
	new.Position = UDim2.new(xnew,0,1,0)
	new.Text = "+"..format(Strength.Value)
end

--<< TOOL FUNCTIONS >>--
tool.Equipped:Connect(function()
	
	fire(bodyAttach)

	toolGrip.Part0 = char[torsoPart]
	toolGrip.Part1 = bodyAttach

	idleAnim:Play()
	print("Hmmm")
end)

tool.Unequipped:Connect(function()

	fire()
	
    shootAnim:Stop()
	idleAnim:Stop()
end)



tool.Activated:Connect(function()
	
	local WaitTime = os.time() + 1
	
	if not debounce then
		debounce = true
		ShowPoints()
		shootAnim:Play()
		wait(WaitTime - os.time()) -- Also 1 seconds
		debounce = false
	end
end)

It works fine when you first spawn in but when you reset the “Tool Grip”'s part 0 and part 1 are complitely impty. I tried waiting for the Body attach or Upper Torso, still dosen’t work :confused:

Can anyone help me?

1 Like

Try this instead of your while character.Parent == nil do loop:

local humanoid = player.Character:WaitForChild("Humanoid")

while humanoid and not humanoid:IsDescendantOf(workspace) do
    humanoid.AncestryChanged:Wait()
end

It usually fixes animation loading related problems with tools but its just a probable fix and isn’t guaranteed to fix.

Also, you put a “Hmm” print so make sure that prints after reset so it ensures that the script actually tried to set the Part0 and Part1 properties.

1 Like

Unfortunately, it doesn’t seem to fix it, It looks like the loop loops forever and doesn’t let the script run. :confused:

After I reset my character not once have I seen the “Hmm” print statement printed in the output, but if I get rid of the ‘while loop’ then it gives out that error:

  09:01:51.378 - LoadAnimation requires the Humanoid object (Grayuu.Humanoid) to be a descendant of the game object

and also stops the script from running, what can I do to fix this?
It seems like when I reset the script just breaks?

Never mind I fixed it my self, the problem was to use ‘plr.CharacterAdded:Wait()’ instead of ‘plr.Character or plr.CharacterAdded:Wait()’ because when you are using ‘or’ it will decide itself which one to use :smiley:

So the problem was on the client side part not on the server side.

4 Likes

I don’t understand step 4 could u give a screenshot or something to show me how it works

Hello, I know it been ages ago but can you tell us how you did that please? I was trying to figure out how to do something like that but with no success. Thank you

Will this method work with Pseudo Tools too?

Is it just me or the toolgrip motor6D isn’t popping up? That is really weird I have no idea why.

Edit:I fixed this issue by putting a wait() before parenting the Motor6D. I have no idea why this works. The throwing animation still does not work properly though. I somehow managed to make it work on an NPC though…man this is odd…I will definitely make a video tutorial on this for future ppl if I figure this out. Learning this is a pain. I used Moon Animation Suite for this.

So basically, gun must be parent of character? D:

Anyone could make a test place for we can check the way it’s done? :stuck_out_tongue:

Is there an easier way to animate the mag than manually setting each keyframe because it’s not connected to the arm? For a reload animation btw.

You could weld the mag to the hand/arm (depending on if you’re using r6 or r15). But then that will mean the mag will always be welded to the hand, so a reload animation might not be possible.

Unless you wanted to animate it so that the mag goes inside your hip to give the illusion that it’s left your hand.

I did it but there’s still that annoying small delay in the animation others seem to have had, clueless how to fix that tried many fixes.

i don’t know why but this pops up everytime i equip the weapon image

the animation wont play too

here are both of the scripts

Client:
local karambit = script.Parent.karambit
local weapon = script.Parent
weapon.Equipped:Connect(function()

local grab = Instance.new("Animation")
grab.AnimationId = "rbxassetid://6410701381"

game.ReplicatedStorage.ConnectM6D:FireServer(karambit.BodyAttach)

char.Torso.ToolGrip.Part0 = char.Torso
char.Torso.ToolGrip.Part1 = karambit.BodyAttach

end)

weapon.Unequipped:Connect(function()

game.ReplicatedStorage.DisconnectM6D:FireServer()

end)

Server:
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)

	local M6D = Instance.new("Motor6D", char.Torso)
	M6D.Name = "ToolGrip"
end)

end)

game.ReplicatedStorage.ConnectM6D.OnServerEvent:Connect(function(plr,location)

local char = plr.Character
char.Torso.ToolGrip.Part0 = char.Torso
char.Torso.ToolGrip.Part1 = location
local grab = Instance.new("Animation")
grab.AnimationId = "rbxassetid://6410701381"

end)

game.ReplicatedStorage.DisconnectM6D.OnServerEvent:Connect(function(plr)
plr.Character.Torso.ToolGrip.Part1 = nil
end)

Any tips on how to move the entire gun when animating? I find it hard to move the entire gun out of the rig, since I want to position it before animating the gun parts.
edit:nvm im incredibly stupid, you can just move the bodyattach and the whole gun will move lol

Well this topic is a bit outdated, because I managed to do your problem by rigging what I need to where I need. I did a Revolver, and I did not rig every single part to the BodyAttach, I rigged what I needed like bullets to the mag space and the mag space to front frame and so like that. You get me?

1 Like