Issue with Motor6D animations

There’s this bug that’s been going around with my game ever since I made my first update.
In this game, you spawn as a custom character which you choose, and each character has their own weapon (A tool).

The thing is, the animations are connected with several Motor6D’s (1 for the Right Arm), another for the Left Arm if the weapon is dual wielded.

The way it works is that the Right Motor6D is connected to the Right Arm and the BodyAttach (main part of the weapon), but for some reason, sometimes the weapon moves inside the character’s stomach, but this doesn’t happen with the weapon on the left (In case the character is dual wielding.)

This is what should happen (and it happens most of the time.)
How it looks most of the time

This is when the bug happens sometimes.
When the bug happens

This is my Local Script (Since the only affected Motor6D is the one at the right.)

local toolGrip = Character:WaitForChild("Right Arm"):WaitForChild("ToolGrip")
local bodyAttach = Tool:WaitForChild("BodyAttach")

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

Tool.Equipped:Connect(function()

	fire(bodyAttach)

	toolGrip.Part0 = Character["Right Arm"]
	toolGrip.Part1 = bodyAttach

	game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
	wait(Module.EquipTime)
	game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)

end)

Tool.Unequipped:Connect(function()

	fire()

end)

This is my Server Script.

game.ReplicatedStorage.Remotes.ConnectM6D.OnServerEvent:Connect(function(p, location, secondlocation)

	if p and p.Character and p.Character:FindFirstChild("Right Arm") and p.Character["Right Arm"]:FindFirstChild("ToolGrip") then
		p.Character:WaitForChild("Right Arm").ToolGrip.Part0 = p.Character:WaitForChild("Right Arm")
		if location then
			p.Character:WaitForChild("Right Arm").ToolGrip.Part1 = location
		else
			p.Character:WaitForChild("Right Arm").ToolGrip.Part1 = location
		end
	end
	if p and p.Character and p.Character:FindFirstChild("Left Arm") and p.Character["Left Arm"]:FindFirstChild("ToolGrip") then
		p.Character:WaitForChild("Left Arm").ToolGrip.Part0 = p.Character:WaitForChild("Left Arm")
		if secondlocation then
			p.Character:WaitForChild("Left Arm").ToolGrip.Part1 = secondlocation
		else
			p.Character:WaitForChild("Left Arm").ToolGrip.Part1 = secondlocation
		end
	end

end)

I’ve tried many things from other topics, I even tried changing the C0 of the Motor6D, but then it just makes the tool move out of place, I’m getting desperate…

I don’t know for sure if this is the cause, but in your server side code, you have two if statements checking location and secondlocation. But in your else exception you have the same line (so if either of those are nil then you are setting your ToolGrip part1 to nil).

Yeah, this is used to disconnect the Motor6D when the weapon is unequipped (that’s why I added the fire() function when the tool is unequipped as well.)

I believe it’s a replication bug with animations that occurs when new Motor6D s are created. This other post seems to face the same issues.

Not sure if it’s a Roblox bug or a implementation bug. But definitely look into replication where lag occurs and how it could effect your script like when certain animations load relative to when the motor6D s are created and stuff.

1 Like

I tried that solution, and it seemed to work, but the bug still happens if there’s a lot of players…

Does it have to do with the remote events? Should I split them into several remotes?