Putting button inside viewportframe inside a UIGridLayout

Basically im trying to make a menu for the avatar editor in my game, and viewportframes are used to display items, but I need to be able to click on them.
Using hacky methods isn’t really reliable, so I was wondering if it was possible to put a ui button inside a viewportframe while it’s being affected by a UIGridLayout.

Any other methods would be great too.
Didn’t really know what to put this under so it’s just under scripting support

1 Like

You could, alternatively, create a frame containing the viewport and button, and set the zindex of the button higher than the viewport.

wouldn’t work, it’s a uigridlayout, everything is placed in a grid and even if I put the button outside the grid, I’d have no way to find the viewport’s position

I’m not understanding why formatting it like this would impose on any of the issues you listed?

image

Additionally, for future reference, a post like this better belongs in Art Design Support I believe.

yea why wouldnt you do the reverse; make a frame, put a vpf in it, alongside a button.

@Reforging example is how it should be done–I suppose idk why u want a vpf and then a button, maybe provide a picture to see what the issue is

Are you trying to say I need to make a frame for every viewport, because that would be a pain to do due to the fact it’s already inside a scrolling frame

you can’t click on viewportframes, but yeah his method should work.

tried it, didnt work, the things inside the frame just do not show up,
image
image

You could parent the buttons to whatever GuiObject the ScrollingFrame is parented to, that way they wouldn’t abide to the formatting enforced by the “UIGridLayout” instance, this is albeit hacky.

no I couldn’t, there would be no way to position the buttons over the viewportframes, you can’t get the position of a gui object affected by a uigridlayout

If you’re positioning/sizing using the scale components of UDim2 values then you can use the “AbsoluteContentSize” property of the UIGridLayout instance (with a bit of math involved).

If you don’t want to go down that route then I suggest you create a backing frame (a container for the viewport frame and the button), this will work with the UIGridLayout.

if you saw the above posts you’d see this was already suggested and tried, it did not work. I’ll probably mess with it more tomorrow, though.

I’ve tried this. Been messing around with it for awhile and the things inside the frame just aren’t affected by the grid.

image

sorry I didn’t originally read your question correctly, but this still wouldn’t have worked because the button wouldn’t appear overtop of the viewport, which is what needs to happen.

figured it out, kinda, im not actually 100% sure how I fixed it, but it works now.