How to create a system to move a frame up and down a scrolling frame with a "UIListLayout"

hello developers! im trying to create a system that changes the placement of the frames in the UIListLayout. here is an example:

image

if you would press the up button on the “stone miners” job, it would move to the top. if you pressed down on the “wood choppers” job, it would be at the bottom. if anybody knows how to make a system like this, could you please teach me how you did it? thank you!

maybe make a local script inside the arrow button that when a player clicks on the button the frame moves down or up
for example

script.Parent.Activated:Connect(function()
    local Frame = -- enter your frame here
    Frame.LayoutOrder == Frame.LayoutOrder - 1 -- if you are doing the down button, then replace "-" to "+"
end)

if it doesnt do anything add a UiListLayout on the frame (if the old one breaks)

wait, i forgot to put something in the script

replace that to

script.Parent.Activated:Connect(function()
    local Frame = -- enter your frame here
    local Layout = Frame.LayoutOrder
    if Layout <= 0 then
        -- do what you want if the Frame is at the top
    elseif Layout >= 4 then  -- if you have like 6 Jobs replace the 4 to 6, if you have 2 Jobs then replace it to 2
        -- do what you want if the Frame is at the bottom
    else
        Layout = Layout - 1 -- if you are doing the down button, then replace "-" to "+"
    end

    Frame.LayoutOrder == Layout
1 Like

hmm it doesnt seem to be working. this is the error:

i think i have an idea of how to do it myself. thank you for your help tho :slight_smile: