How to fix rig bug?

I’ve had this problem for quite a while and i have been scratching at it for so long.
so I have this rig that has motor 6ds to attach a gun to the right arm.
and I’ve got it to animate the gun in moon animator. However in game. the gun does not play the animation and only the character.
I do have another rig with a item attached to it same way and works fine. I’m not sure if it my rigging or scripts.


function Characters.Trail(CurrentCharacter)
	for _, Character in ipairs(MainCharacters:GetChildren()) do
		if table.find(Characters.AliveCharacters, Character.Name) and Character.Name ~= Characters.CurrentCharacter then
			local CharacterHRP = Character:FindFirstChild("HumanoidRootPart")
			local Index = table.find(Characters.AliveCharacters, Character.Name)
			local FrontCharacterHRP = CheckCharacterIndex(Index, CurrentCharacter)

			if FrontCharacterHRP and CharacterHRP then
				local TargetCFrame = FrontCharacterHRP.CFrame * CFrame.new(0, 0, 3.5)
				task.delay(0.01, function()
					CharacterHRP.CFrame = CharacterHRP.CFrame:lerp(TargetCFrame, 0.1)
				end)
			end
		end
	end
end

function Characters.SwitchPositions(CurrentCharacter, OldCharacter)
	local TakenCFrame = CurrentCharacter.HumanoidRootPart.CFrame
	CurrentCharacter:PivotTo(OldCharacter.HumanoidRootPart.CFrame)
	OldCharacter:PivotTo(TakenCFrame) 
	
	for _, Character in ipairs(MainCharacters:GetChildren()) do
		if table.find(Characters.AliveCharacters, Character.Name) and Character.Name ~= Characters.CurrentCharacter then
			local CharacterHRP = Character:FindFirstChild("HumanoidRootPart")
			local Index = table.find(Characters.AliveCharacters, Character.Name)
			local FrontCharacterHRP  = CheckCharacterIndex(Index, CurrentCharacter)

			if FrontCharacterHRP and CharacterHRP then
				local TargetCFrame = FrontCharacterHRP.CFrame * CFrame.new(0, 0, 3.5)
				CharacterHRP.CFrame = TargetCFrame
			end
		end
	end
end

function Characters.SwitchCharacter(Player, Index)
	
	pcall(function()
		Connection:Disconnect()
		Connection = nil
	end)
	
	local OldCharacter = Player.Character
	if not OldCharacter or not OldCharacter:FindFirstChild("HumanoidRootPart") then return end
	
	local OldHumanoid = OldCharacter:FindFirstChildOfClass("Humanoid")
	if OldHumanoid then
		OldHumanoid:Move(Vector3.new(0, 0, 0)) 
		local OldAnimator = OldHumanoid:FindFirstChildOfClass("Animator")
		if OldAnimator then
			for _, track in ipairs(OldAnimator:GetPlayingAnimationTracks()) do
				track:Stop(0.5) 
			end
		end
	end
	
	Characters.CurrentCharacter = Characters.AliveCharacters[Index]
	if Characters.CurrentCharacter == nil then return nil, Characters.AliveCharacters end
	local Character = MainCharacters[Characters.CurrentCharacter]
	
	Characters.SwitchPositions(Character, OldCharacter)
	
	Player.Character = nil
	task.wait()
	if OldCharacter.Name ~= Player.Name then
		if OldCharacter:GetAttribute("HealthPoints") <= 0 then
			OldCharacter.Parent = workspace.Dead
			Ragdoll.Ragdoll(OldCharacter)
		else
			OldCharacter.Parent = MainCharacters
		end
	end
	
	Player.Character = Character
	
	local rootPart = Character:WaitForChild("HumanoidRootPart", 5)
	if rootPart and rootPart:IsDescendantOf(workspace) then
		rootPart:SetNetworkOwner(Player)
	end
	
	if Character then
		CharacterChangeRemote:FireAllClients(Character)
	end
	
	task.wait()

	Connection = RS.Stepped:Connect(function() Characters.Trail(Character) end)
	
	return Character, Characters.AliveCharacters
end

I’ve rounded my options up to this module script i have. Please send feedback ASAP

1 Like

I actually just found the problem. Turned out the model had its own humanoid

2 Likes

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