spawn(function () local InventorySlots = script.Parent.Parent.Parent:GetChildren() for _, slot in pairs (InventorySlots) do if slot.ClassName == "Frame" then slot.Detector.MouseEnter:Connect(function () SlotToInsert = string.sub(slot.name, 5, -1) end) end end end)
I've added this piece of code above to connect a function to any inventory slot that changes the current slot ID to the slot ID of the inventory slot when the mouse touches the slot
I've created a custom GUI inventory for my game. Now I want to create a drag and drop system for it. I have already set up a server script that can replace the slot values of two specified slots. The only problem is that I do not know how to do the actual drag and drop. Basically I would like to know, how I can create a system that if I drag an Image Button on another ImageButton and drop it returns the 2 SlotIDs of the 2 Images Buttons
ScreenGUI Inventory Frame Slot List Slot (1-27) Image SlotID
My attempt:
script.Parent.MouseButton1Down:Connect(function () local Mouse = game.Players.LocalPlayer:GetMouse() Dragging = true script.Parent.Parent.Description.Visible = false FireFunction = false while Dragging == true do script.Parent.Parent.Parent.Parent.Parent.DragAndDropImage.Image = script.Parent.Parent.ItemImage.Image wait () local mouseLocation = (UserInputService:GetMouseLocation()) script.Parent.Parent.Parent.Parent.Parent.DragAndDropImage.Visible = true script.Parent.Parent.Parent.Parent.Parent.DragAndDropImage.Position = UDim2.new(0, mouseLocation.x - 40, 0, mouseLocation.y - 70) script.Parent.Parent.ItemImage.Visible = false if (UserInputService:IsMouseButtonPressed (0)) == false then print (UserInputService:GetMouseLocation()) Dragging = false script.Parent.Parent.Parent.Parent.Parent.DragAndDropImage.Visible = false script.Parent.Parent.ItemImage.Visible = true end end end)
This attemt works perfectly except for returning the slot IDs