Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[SOLVED] Inventory item dragging: how do I track a GUI's location in a certain space?

Asked by
aredanks 117
4 years ago
Edited 4 years ago

I want to create an inventory item dragging system but to do that I first must make it draggable. I would have the player hold their mouse button and the GUI image is stuck to the mouse cursor until the client lets go of it.

Now for the problem I described in the title, I want to detect where it's located so that if I drag the item to an empty item slot, the script knows which slot it should be placed in. If I drag it to a hotbar slot, the script will know where to place so item in that slot while emptying its prior slot it was dragged from.

I however have no clue how to do something like that and the closest thing I know to such is Region3 but there may be more efficient ideas than comparing it to Region3 but with GUIs.

0
i swear there's a way to learn if 2 gui elements are overlaying or touching each other, it's on the roblox developer hub somewhere, ill keep searching Lunaify 66 — 4y
0
but i think they removed the gui touching tutorial, because the last time i saw it was 2 years ago when the roblox developer hub used to be called the roblox wiki Lunaify 66 — 4y
0
Thanks for the help. aredanks 117 — 4y

1 answer

Log in to vote
0
Answered by
aredanks 117
4 years ago

There is an event designed to detect the mouse's presence in GUI elements called .MouseEnter.

It can be used on inventory slots in a client script while detecting if the client is already dragging an item.

GuiObject events: https://developer.roblox.com/en-us/api-reference/class/GuiObject

Ad

Answer this question