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

How can I put a limit on UiGridLayout?

Asked by 3 years ago
Edited 3 years ago

I have a boombox script that saves audios to the roblox data store so it saves people form having to type in the same audio ID constantly, and I use the UiGridLayout to properly fit all of the saved audios onto one frame. My problem here is that when you go over 13 saved audios it goes onto the next column, so how would I go about putting a limit on the amount of saved audios. Example for what I want it to do: if the amount of saved audios go over 13 then the bottom most saved audio will delete so it can fit the most recently added saved audio to the frame.

The problem - https://imgur.com/a/OFAGXpz The Gui - https://imgur.com/a/KhcyrHP

In the "ListOfMusic" frame showed in the picture above contains the MusicInfo (which is where the audios are stored) and as you can see there are over 13 which breaks the gui (shown in "The Problem" link).

2 answers

Log in to vote
0
Answered by
pwx 1581 Moderation Voter
3 years ago

You could try putting them into a table, maybe? By default the last value of a table would be the newest value added and the first value being the oldest.

local audios = {}

table.insert(audios, newAudio)

if #audios > 13 then -- more than 13
    table.remove(audios, 1) -- oldest value 
end

for _,audio in pairs(audios) do
    -- here I would loop through said audios in table and place them into the UI, maybe?
end

I dunno maybe I'm putting too much code into, do bare with me I've just woken up.

Ad
Log in to vote
0
Answered by 3 years ago

Use pwx's code, it works really good....... i think.... u just have to make i GUI i think

Answer this question