I need help with playing this animation properly

I am not sure if this is the right topic

BEFORE YOU READ

My model is NOT a tool, so using most tutorials won’t work.

Hi everyone, I recently made a hammer model as a part of a challenge, and I’m currently trying to script it. My script does work, my only problem is that the hammer’s handle isn’t going where it should be.

Here’s what it should look like:

And here’s what it looks like in-game:

This is my script I used for my hammer, keep in mind that my hammer is NOT a tool, but a model that is stored in the workspace. The script goes into StarterCharacterScripts.

local swinganim = script:WaitForChild("SwingAnimation")
local swinganimtrack
local canswing = true
local Human = script.Parent:WaitForChild("Humanoid")

mouse = game.Players.LocalPlayer:GetMouse()

mouse.KeyDown:connect(function(key)
	key = key:lower()
	if key == "f" and canswing then
		canswing = false
		print("Swung hammer")
		if not swinganimtrack then swinganimtrack = Human:LoadAnimation(swinganim) end
		swinganimtrack:Play()
		Human.WalkSpeed = 0
		Human.JumpPower = 0
		local weld  = Instance.new("Motor6D")
		local hammer = game.Workspace.Hammer
		hammer.Handle.Transparency = 0
		hammer.Parts.Bands.Transparency = 0
		hammer.Parts.Shaft.Transparency = 0
		hammer.Parts.Top.Transparency = 0
		hammer.Parts.Connector.Transparency = 0
		hammer.Parent = Human.Parent
		weld.Parent = Human.Parent:WaitForChild("Right Arm")
		weld.Part0 = Human.Parent:WaitForChild("Right Arm")
		weld.Part1 = hammer.Handle
		wait(0.5)
		hammer.Parent = game.Workspace
		hammer.Handle.Transparency = 1
		hammer.Parts.Bands.Transparency = 1
		hammer.Parts.Shaft.Transparency = 1
		hammer.Parts.Top.Transparency = 1
		hammer.Parts.Connector.Transparency = 1
		weld:Destroy()
		print("Can swing again")
		Human.WalkSpeed = 18
		Human.JumpPower = 30
		canswing = true
	end
end)

I’m not sure what could be causing this issue, it might be how I welded it or animated it but I’m still not sure.

Thank you for reading and considering to help me!

1 Like

It looks like the hammer head isn’t welded properly and it must be faced properly

I just tested it and that wasn’t the issue, all the welds are working properly

If you use moon weld the hammer head you can weld that in position to permanently face the way you want it but I don’t see anything changing position in this script

Looks like you’re animating the tool. To animate the tool you need to use motor6D.

Here is a tutorial on it:

I just checked the tutorial and it won’t work since my model isn’t a tool. It’s stored in the workspace and is welded to the player when needed. I might be able to edit it a bit though, I’ll respond if I get it to work.

It doesn’t only work on tools it can still work all you need is just to add in motor6D and remove the welds like the tutorial. (Not sure if it’ll work 100%)

why not make it a tool or accessory that would make it much easir?

1 Like

I’m trying not to add tools to my game, even if it’s easier for me. I need to practice this type of scripting if I want to get better.

1 Like

The reason the handle is not changing like in the animation is because welds don’t allow that, motor6D’s are used to animate the objects like in the animation. (Wonder why characters use motor6D instead of welds?)

2 Likes

This worked, thanks for the help!
image

1 Like

Characters probably use Motor6D so they can move properly when animating, if you remove them then your rig breaks

2 Likes