Issue with Motor6D between player arm and tool

Hello,
So basically I have a tool when equipped will create a motor6D that connects between player’s Right Arm and tool’s primary part.

When first equipped, it works fine. But after dying, it does nothing? The rest of the thread still run, until it comes up with loading an animation for it… the motor6D is required (it’s an animated tool).

devforum image #1

  • yellow circle is the referred tool

Here is a piece of my code. Looks simple right? It runs on client/LocalScript.

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

tool.Equipped:Connect(function(mouse)
	grip = Instance.new("Motor6D")
	grip.Name = "ToolGrip"
	grip.Parent = character["Right Arm"]
	grip.Part0 = character["Right Arm"]
	grip.Part1 = tool.BodyAttach -- Tool's primary part.
end)

That’s not the only problem. The thing is, I also have another tool that has the same grip function. However it works completely fine even after dying?

Thank you for reading, feedbacks are appreciated :slightly_smiling_face:

1 Like

You could try connecting it on the server using a remote event

-- In the local script
local RemoteEvent -- Define the remote event
tool.Equipped:Connect(function()
	RemoteEvent:FireServer(tool, true)
end)

tool.Unequipped:Connect(function()
	RemoteEvent:FireServer(false)
end)

-- In a server script
local RemoteEvent -- Define the remote event
RemoteEvent.OnServerEvent:Connect(function(player, tool, bool)
	if not tool then return end
	if bool == nil then return end
	local character = player.Character
	if not character then return end
	if bool == true then
		if character["Right Arm"]:FindFirstChild("ToolGrip") then
			character["Right Arm"].ToolGrip.Part1 = tool.BodyAttach
		else
			local grip = Instance.new("Motor6D", character["Right Arm"])
			grip.Name = "ToolGrip"
			grip.Part0 = character["Right Arm"]
			grip.Part1 = tool.BodyAttach
		end
	elseif bool == false then
		if character["Right Arm"]:FindFirstChild("ToolGrip") then
			character["Right Arm"].ToolGrip.Part1 = nil
		end
	end
end)

Also if you haven’t done this already, make sure the RequiresHandle property of the tool is disabled. You’d have to create your own “Handle” which I’m guessing you’ve already done and it’s called BodyAttach.

1 Like

Now it welds, but yet after dying, the animation won’t load…
“Cannot load the AnimationClipProvider Service”

I had the same problem with my game and my solution was to put them in StarterGear or a place where the tool won’t be lost on death. Then, before the player’s character is removed, you parent the tools to StarterGear.

-- In a server script
game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local humanoid = character:WaitForChild("Humanoid")
		humanoid.Died:Connect(function()
			for i, v in pairs(character:GetChildren()) do
				if v:IsA("Tool") then
					v.Parent = player:WaitForChild("StarterGear")
				end
			end
		end)
	end)
end)

I tried this, and it doesn’t do anything with it… I haven’t heard about StarterGear. Is it the same like StarterPack?

Edit: I tried putting the tool in ServerStorage or somewhere not for starter, and that fixed it! But how and why though? And I’m still wondering about the other tool…

StarterGear is essentially like backpack except it’s meant to hold a player’s gear. Tools aren’t lost when they are in StarterGear or another container similar to it. When you load an animation for a tool, the animation only loads for the specific tool. When you die and respawn, you wouldn’t have the tool that the animation is loaded for, so the animation breaks. Hope that makes sense

1 Like

Wouldn’t it be the different Animator inside since it’s a newer character?
Here’s the same script again but with the animation-loading part:

tool.Equipped:Connect(function(mouse)
	grip = Instance.new("Motor6D")
	grip.Name = "ToolGrip"
	grip.Parent = char["Right Arm"]
	grip.Part0 = char["Right Arm"]
	grip.Part1 = tool.BodyAttach
	
	isEquipped = true
	canShoot = true
	
	game:GetService('RunService').Stepped:Wait()
	local animator = char.Humanoid:FindFirstChild("Animator")
	IDLE = animator:LoadAnimation(script.Idle)
	SHOOT = animator:LoadAnimation(script.Shoot)
	RELOAD = animator:LoadAnimation(script.Reload)
	
	IDLE:Play()
end)

I still think it’d be the tool animation because when the player dies, a new animator is always placed in the humanoid. If the tool disappears after death, then the script will error, but if the tool is placed where it won’t disappear (like ServerStorage), then the script won’t error. That’s just my thought process though lol. You could experiment with it like keeping the same Animator after a player dies and then replacing the new one with the old one and seeing what happens.

I see now… thank you for the responses and explanations! :smile:

1 Like