Adding tools to an animation?

I’ve got a hammer ingame and it plays an animation when activated, this animations includes the handle, I made a joint in the animation rig and added the handle, uploaded the animation and stuff

Problem is the tool isn’t animating INGAME, the handle doesn’t move

(I somewhat solved this but there is still an issue, look at “EDIT 2” down below)

Proof:
– // Ingame

– // In animation editor

Then I have this ServerScript inside the tool that makes a Motor6D when equipped

local tool = script.Parent
local plr = tool.Parent.Parent
local char = plr.Character or plr.CharacterAdded:Wait()

tool.Equipped:Connect(function()
	
	local M6D = Instance.new("Motor6D")
	M6D.Name = "Tool"
	M6D.Part0 = char:FindFirstChild("RightHand") or char:FindFirstChild("Right Arm")
	M6D.Part1 = tool.Handle
	
	M6D.Parent = char:FindFirstChild("RightHand") or char:FindFirstChild("Right Arm")
	
end)

tool.Unequipped:Connect(function()
	local arm = char:FindFirstChild("RightHand") or char:FindFirstChild("Right Arm")
	
	arm:FindFirstChild("Tool"):Destroy()
	
end)

and a LocalScript that plays the animation

I know the animations look the same, but in the animation editor the hammer is tilted slightly.
I can tell by the angle that it isn’t playing ingame.

Sorry if it’s a long topic I needed to explain myself
HELP

(Edit: tried using moon animator yet I couldn’t get it to work)

EDIT 2:

Seems like the reason my tool wasn’t animating is because the Motor6D was not activated when created because there was already a weld from the RightHand to the Handle, which is the default RightGrip weld Roblox makes for tools

Deleting this weld and replacing it with my own Motor6D did somewhat work but not perfectly
Now the animation doesn’t play properly

1 Like

wooooow… thats really uproarious…

I think you meant adding animations to tools. But this article will help: https://create.roblox.com/docs/tutorials/building/animation/scripting-avatar-animations

the animations look the same?

I couldn’t find anything of use in that doc, I want the tool (hammer) to be a part of the playing animation, If i wanted to make float in the animation, I need to add the tool, to the animation.

As I mentioned in the original post, they’re similar but in the actual animation, the handle is tilted a little

Showcase:

This is the handle:
image

Whats the animation priority

The animation priority is action

image

Hm weird, try setting it to Action 4. If that’s still not working maybe double check the m6d was parented to the correct spots on the player model. it should be the same setup as the one you have in the animator

Action 4 did not work, I’ll retry the m6d thing but it’s important to note that for some reason the M6D isn’t active
image

Well, code-wise, it’s great. I added checks to ensure required parts exist, preventing errors if, for example, “RightHand” or “Right Arm” is not found in the character. You could also initialize variables for the player and the character and work with them once you have the tool equipped.

local playersService = game:GetService('Players')
local tool = script:FindFirstAncestorWhichIsA('Tool')
local player, character

tool.Equipped:Connect(function()
	character = tool.Parent
	player = playersService:GetPlayerFromCharacter(character)
	local rightHandOrArm = character:FindFirstChild("RightHand") or character:FindFirstChild("Right Arm")

	if character and rightHandOrArm then
		local motor6d = Instance.new("Motor6D")
		motor6d.Name = "Tool"
		motor6d.Part0 = rightHandOrArm
		motor6d.Part1 = tool.Handle
		motor6d.Parent = rightHandOrArm
	end
end)

tool.Unequipped:Connect(function()
	if typeof(character) == 'Instance' then
		local rightHandOrArm = character:FindFirstChild("RightHand") or character:FindFirstChild("Right Arm")
		if rightHandOrArm then
			rightHandOrArm:FindFirstChild("Tool"):Destroy()
		end
	end
end)

Just in case you need something to do with the player, it’s defined there.

Thanks! I mean It’s still not playing correctly but thank you either way

Found the solution myself

After deleting the default RightGrip, I just had to playtest, copy my character with the tool equipped and use it as a dummy to make the animation.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.