Attachment points not lining up on gun when animated

I’m working on a gun in my game and the Muzzle flash effect attachments and bulletpoints arent staying where their suppose to be

So this is wheres the attachments are suppose to be in the gun

This video shows the problem

So basically the attachments arent staying on the gun, i used this GripToMotor6D script and i think thats where my problem is.

local motorName = "Handle"

	local player
	local character
	local humanoid
		local isR15
	local rightHand

do
	script.Parent.Equipped:connect(function()
		if player == nil then
			player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
		end
		if character == nil or character.Parent == nil then
			character = script.Parent.Parent
			humanoid = character.Humanoid
				isR15 = humanoid.RigType == Enum.HumanoidRigType.R15
			rightHand = isR15 and character:WaitForChild("RightHand") or character:WaitForChild("Right Arm")
		end
		local getWeld = rightHand:WaitForChild("RightGrip")		
		local motor = Instance.new("Motor6D")
		motor.Name = motorName
		motor.Part0 = getWeld.Part0
		motor.Part1 = getWeld.Part1

		getWeld:Destroy()
		motor.Parent = rightHand
	end)
end