Inventory dragging problems

Hello everyone, so i am currently making a Inventory sorting dragging system and i seem to be in a road block everytime i drag again it does not correctly select the right slot here is a gif and some of my code that i have , if you could help me that would be great! thanks

https://gyazo.com/0d669bc4a167d31d7734c3e79e903d9f

v.DragStopped:Connect(function()
			for i , e in next, script.Parent:GetChildren() do
				if e:IsA("GuiObject") then
					if v.Name ~= e.Name then
						local distance = (v.AbsolutePosition - e.AbsolutePosition).Magnitude
						if distance < e.AbsolutePosition.Magnitude / 9 then
							wait(.23)
							v:TweenPosition(defualtpos[e.Name],Enum.EasingDirection.Out,Enum.EasingStyle.Sine,0.2)
							e:TweenPosition(defualtpos[v.Name],Enum.EasingDirection.Out,Enum.EasingStyle.Sine,0.2)
							print(e.Name)
						end
						v:TweenPosition(defualtpos[v.Name],Enum.EasingDirection.Out,Enum.EasingStyle.Sine,0.2)
					end
				end
			end
		end)
4 Likes

i have found the issue i forgot to change the name of the item every time i swap my bad sorry guys :confused:

result ; https://gyazo.com/42f614b84dcb948e4d5cd74bf338eaae