Motor6D Problem

What do I want to achieve?
I want the animation in my game to play correctly.

What is the issue?
I’m experiencing problems with animating when the player equips a bat. When NPCs equip the bat, the animation plays correctly, but when the player does it, the animation doesn’t play the way I want it to.

What solutions have I already tried?
I was looking for solutions, but I still haven’t found it.

Code:

local Track

script.Parent.Equipped:Connect(function()
	local Char = script.Parent.Parent;

	local Motor6D = Instance.new('Motor6D')
	Motor6D.Part1 = script.Parent.Handle
	Motor6D.Part0 = Char:WaitForChild('Right Arm')
	Motor6D.Parent = Char:WaitForChild('Right Arm')

	local a:Weld = Char:FindFirstChild("Right Arm"):WaitForChild("RightGrip")
	a:Destroy()

	Track = Char:WaitForChild("Humanoid"):LoadAnimation(script.R6_Holding)

	if Track then
		Track:Play()
		print("ANIM PLAY")
	end
end)

script.Parent.Unequipped:Connect(function()
	if Track then
		Track:Stop()
	end	
end)

3 Likes

This MIGHT be because of AnimationPriority, so another animation could be affecting it. Maybe set the priority higher?

I set action 4, but it didn’t help :frowning:

Looking through your code the only thing I can think if that makes the problem scripting related is that your using :LoadAnimation() on the Humanoid, when you should use it on Humanoid.Animator.
Try changing the line of code to

Track = Char:WaitForChild("Humanoid").Animator:LoadAnimation(script.R6_Holding)

The same problem persists, nothing has changed.

Alright, I didn’t know if it would change anything for sure. Could you send a file of the place with the tool in it so I can look into this a bit more?

Can you post your updated code with the animation priority change?

FOR_DEV_FORUM.rbxl (82.4 KB)

By the way, try making the animation play on the client.

I didn’t modify the priority through a script.

Ah I see. Try doing it anyway to see if it has any effect (Track.Priority = Enum.AnimationPriority.Action4)

Is this a local script or server script?
From what I’ve seen Animations are played on the client using local scripts.
They may play fine on NPCs because they are owned by the server.

It is a server script, which is why I told him to attempt to make it with a localscript:

By the way, try making the animation play on the client.

It works, but is it possible to reduce its priority to ‘idle’ instead of having such a high priority?

Alright. I opened the file and had to remake the animation because it wasn’t uploaded by me, but after doing that it seems to work fine… Weird.

Here’s my code

local Track

script.Parent.Equipped:Connect(function()
	local Char = script.Parent.Parent;

	local Motor6D = Instance.new('Motor6D')
	
	Motor6D.Part0 = Char:WaitForChild('Right Arm')
	Motor6D.Part1 = script.Parent.Handle
	Motor6D.C0 = CFrame.new(0, -1, 0, 1, 0, -0, 0, 0, 1, 0, -1, 0)
	Motor6D.C1 = CFrame.new(0, -1.15548325, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
	
	Motor6D.Parent = Char:WaitForChild('Right Arm')

	local a:Weld = Char:FindFirstChild("Right Arm"):WaitForChild("RightGrip")
	a:Destroy()

	Track = Char:WaitForChild("Humanoid").Animator:LoadAnimation(script.R6_Holding)

	if Track then
		Track:Play()
		print("ANIM PLAY")
	end
end)

script.Parent.Unequipped:Connect(function()
	if Track then
		Track:Stop()
	end	
end)

I mean I guess you could do Movement, but then again it would be overrid when the player walks. There are 4 “Action” priorities, so having it as Action would work if you don’t want to use Action4.

Hmm, it seems I might be doing something wrong. Could you please share a video tutorial on how to do this correctly, or provide step-by-step instructions?

C0 and C1 are just adjusting the position of the bat when its attached to the arm

Edit: NVM I see what they mean. You could also use toolgripeditor to do this.

That wouldn’t work in this case, because he’s welding the bat manually.