Why aren't UIDragDetectors working?

I’m attempting to make an inventory system. I’ve looked all over the DevForum for reasons why, but none of them work. I’ve tried a variety of solutions to no avail.


It also shows that they’re working (when I use DragStart/DragEnd) but it doesn’t actually drag, and the input for the drag immediately ends as it starts.
image

Could you provide a code snippet?

for _,child in pairs(items:GetChildren()) do
	if child:IsA("GuiObject") then
		local initialTransparency = child.BackgroundTransparency
		
		local dragDetector: UIDragDetector = child:FindFirstChild("UIDragDetector")
		dragDetector.DragStart:Connect(function()
			print('DragStart')
			child.Parent = ghostItems
		end)
		
		dragDetector.DragEnd:Connect(function()
			print('DragEnd')
			child.Parent = items
			sort()
		end)
	end
end

This is the only part of the code which actually uses the DragDetector. (Also the sort() function doesn’t change much here- I’ve tried using the code without it, and it still didn’t work.)

I think it might be related to me changing the parents of the UI. I removed those sections and it worked. I think I’ll have to try to find an alternate solution to what I’m trying to do with the GhostItems frame.

Yeah, reparenting the child seems to sorta interrupt the UIDragDetector. If you need help finding another solution, I’d be happy to help.

1 Like