Hello, i am trying to make something that allows a player to move parts around with just moving their mouse, but when i do this the part that they move does not interact correctly. I have been getting the size of the part they are touching but this does not always work. How can i make this better.

v.MouseButton1Click:connect(function()
		if not activated2 then
			activated2 = true
		
		local clicked = false
		local tag = nil
		local untag = nil
		
		if tag == nil then
		 model = Instance.new("Model")
			model.Name = v.Name	model.Parent = game.Workspace
		 clone = game.ReplicatedStorage.CopyItems:FindFirstChild(v.Name):Clone()
			clone.Parent = model
		end
		tag = model
		repeat
			wait(.1)
			if mouse.Target ~= nil and clone:IsA("Part") then
				tag.PrimaryPart = clone
			elseif mouse.Target ~= nil and clone:IsA("Model") then
				tag.PrimaryPart = clone:FindFirstChild("Base")
			end
			 
			if mouse.Target ~=nil then
			tag:SetPrimaryPartCFrame(CFrame.new(math.ceil(mouse.Hit.X -tag.PrimaryPart.Size.X),math.ceil(mouse.Target.Position.Y + tag.PrimaryPart.Size.Y/2 + 1),math.ceil(mouse.Hit.Z +tag.PrimaryPart.Size.Z-.5)))
			end
			mouse.Button1Down:connect(function()
				if not activated then
					activated = true
					
					local Item = nil
					if P:WaitForChild("Inventory"):FindFirstChild(v.Name) ~= nil then
						
					local Item = P:WaitForChild("Inventory"):FindFirstChild(v.Name)
					Item.Value = Item.Value -1
						if v:FindFirstChild("Valued") ~= nil then
							v.Valued.Text = Item.Value
						end
					if Item.Value < 0 then
						v:Destroy()
						model:Destroy()
					end
					if Item.Value == 0 then
						v:Destroy()
						Item:Destroy()
					end
					
					activated2 = false
					clicked = true
					
					end
					local Item = nil
					wait(.25)
					activated = false
				end
			end)
			
		
		until	clicked == true
		clicked = false
		end
	end)