So if i were to trigger MouseEnter() on a gui, how would I know which gui that event was fired from, without having to name every single gui? Is there a better way to do this? I am trying to create an inventory gui.
COMMUNITY QUESTION
How to trace the parent of a triggered event?
1 answer
Use a for loop (iteration)
local inventoryItems = script.Parent.InventoryItems -- Change this to whatever your items are inside.
for i, v in pairs(inventoryItems:GetChildren()) do
v.MouseEnter:connect(function()
print("Mouse entered.")
end)
end)
With this script, v is your GUI and i would be th iterator, or the number of the GUI object in the for loop.
There's most likely a better way to do this, and it might be using UserInputService, I would give you a more detailed answer with info on that but I'm on mobile and it'll take quite a while.
1 comment
0
Thank you! I was getting very frustrated over this because i was trying to find a way to go around it, but i just didn't know how, this makes it a lot easier.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Loop through all slots and have an event