Anyway to get a objects position in a list?

This is kinda hard to explain but, I’m trying to create a custom toolbar / backpack and I need to know what position the imagebutton is in the scrollingframe to know what the number on there keyboard they have to click to equip the tool.

Your properly wondering why can’t you just put the certain number in each equip script? The problem is that when I remove a tool or add a tool to the custom backpack the keybind to equip the tool will not change.

Sorry if this doesn’t make sense as I’ve never seen or heard anything like this and its kind hard to explain when you can’t reference anything.

Image:
image

2 Likes

I don’t know if there is any api in the ui constraints or the ui objects themselves that would tell you that, but if you, say wanted to get in what order some ui objects were in a list left to right, you could just loop through all the items and count any of the ui objects that are further left on the X axis by comparing positions. That count would be it’s order in the list from left to right.

1 Like

Maybe this will help?
https://developer.roblox.com/en-us/api-reference/property/GuiObject/LayoutOrder

Yes, you can change the UIListLayout’s SortOrder into LayoutOrder instead. Thus you can set the UI value of the LayoutOrder after respective key.

3 Likes