UiGridLayout.SortOrder Just fails every single time!

Ok so basically Im trying to make two buttons to sort them by their names, Alphabetically and reverse.
image
if you click the lower button, The “if this went up it worked” is supposted to go up because it turned into enum’s SortOrder.LayoutOrder.
If you click the top one, It goes back down, sorts by name.
image
Those two buttons are supposted to change these ImageButtons.
You can see the first letter changing alphabetical.
image
image
So these two scripts swap layoutorder when its changed. But it just fails horribly. Even when i try changing it manually it wont swap.
image

It seems like the issue is with your script that is attempting to swap the LayoutOrder values of the buttons. Without seeing the full script, it’s difficult to pinpoint the exact issue, but here are a few things to check:

  1. Make sure you’re accessing the correct property of the ImageButton objects. It looks like you’re trying to change the LayoutOrder property, but it’s possible that you’re accidentally modifying a different property.
  2. Make sure you’re actually swapping the values correctly. One common mistake is swapping the values incorrectly or using a temporary variable that is overwritten before the swap occurs.
  3. Check that your event listeners are correctly attached to the buttons and are firing when you expect them to.

Here’s an example script that should swap the LayoutOrder values of two ImageButton objects when a button is clicked:

local button1 = script.Parent.Button1
local button2 = script.Parent.Button2

local function swapLayoutOrder()
    local temp = button1.LayoutOrder
    button1.LayoutOrder = button2.LayoutOrder
    button2.LayoutOrder = temp
end

script.Parent.AlphabeticalButton.MouseButton1Click:Connect(function()
    -- sort buttons alphabetically
    button1.Text = "A"
    button2.Text = "B"
    swapLayoutOrder()
end)

script.Parent.ReverseButton.MouseButton1Click:Connect(function()
    -- sort buttons in reverse order
    button1.Text = "B"
    button2.Text = "A"
    swapLayoutOrder()
end)

This script assumes that you have two ImageButtons with the names “Button1” and “Button2” as children of the same object as the two sorting buttons. It also assumes that the sorting buttons have the names “AlphabeticalButton” and “ReverseButton”, respectively. You’ll need to modify the script to match your specific setup.

I figured it out myself, The problem was the Name’s of the ImageButtons, It had a “-” in it which i dont think roblox registers.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.