I put IntValues in Imagebuttons, This script wont use that to change the LayoutOrder

Basically i wanna change the layoutorder of each button inside “Scroll”
I put intvalues to each button i wanna change its value,
I put simple in one,
Mild in one,
Difficult in one,
I tried this script but its not working

-- Create a table to store the LayoutOrder of the buttons
local dave = script.Parent.Parent
local scroll = dave.Eggdog.Easy.Davez

local function Baby()
for i, child in ipairs(scroll:GetChildren()) do 
	if child:IsA("ImageButton") then 
		for j, intValue in ipairs(child:GetChildren()) do 
			if intValue:IsA("IntValue") then 
				if intValue.Value == "Simple" then
					child.LayoutOrder = 1
					elseif intValue.Value == "Mild" then
						child.LayoutOrder = 2
					elseif intValue.Value == "Difficult" then
						child.LayoutOrder = 3
					
					end
				end
			end 
		end 
	end 
end

local function Baby2()
	for i, child in ipairs(scroll:GetChildren()) do 
		if child:IsA("ImageButton") then 
			for j, intValue in ipairs(child:GetChildren()) do 
				if intValue:IsA("IntValue") then 
					if intValue.Value == "Simple" then
						child.LayoutOrder = 12
					elseif intValue.Value == "Mild" then
						child.LayoutOrder = 11
					elseif intValue.Value == "Difficult" then
						child.LayoutOrder = 10

					end
				end
			end 
		end 
	end 
end

script.Parent["Difficulty(Ascending)"].MouseButton1Click:Connect(function()
	Baby()
end)

script.Parent["Difficulty(Descending)"].MouseButton1Click:Connect(function()
	Baby2()
end)

The value of the intValue has to be an integer, not a string like "simple", "mild", or "difficult", either use a stringValue or change the values into integers.

Ok so i changed the IsA() to a StringValue but the script only changes one of the imagebuttons.

Do the imageButtons all have stringValues as a child, and do they follow the order you give?

Yep, but im afraid the “Child.LayoutOrder = ???” affects ALL Childs

That wouldn’t make sense, however your code is a little messy, instead of:

for j, intValue in ipairs(child:GetChildren()) do 
	if intValue:IsA("IntValue") then 
		...
	end
end

do:

local intValue = child:FindFirstChild("IntValue")
if intValue:IsA("IntValue") then 
	...
end

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