local hairButtons = {
hair1 = hairScrollingFrame:WaitForChild('ViewportFrame1'),
hair2 = hairScrollingFrame:WaitForChild('ViewportFrame2'),
hair3 = hairScrollingFrame:WaitForChild('ViewportFrame3'),
hair4 = hairScrollingFrame:WaitForChild('ViewportFrame4'),
hair5 = hairScrollingFrame:WaitForChild('ViewportFrame5'),
hair6 = hairScrollingFrame:WaitForChild('ViewportFrame6')
}
for key, button in pairs(hairButtons) do
print("Key:", key, "Button:", button)
end
Output:
13:44:11.373 Key: hair5 Button: ViewportFrame5 - Client - LocalScript:32
13:44:11.374 Key: hair4 Button: ViewportFrame4 - Client - LocalScript:32
13:44:11.376 Key: hair2 Button: ViewportFrame2 - Client - LocalScript:32
13:44:11.376 Key: hair1 Button: ViewportFrame1 - Client - LocalScript:32
13:44:11.377 Key: hair3 Button: ViewportFrame3 - Client - LocalScript:32
13:44:11.378 Key: hair6 Button: ViewportFrame6 - Client - LocalScript:32
2 Likes
Katrist
(Katrist)
September 4, 2023, 8:45pm
#2
Dictionaries don’t print in order. Only arrays do.
1 Like
How can I sort this? /////////////////
1 Like
txcIove
(txcIove)
September 4, 2023, 8:49pm
#4
Just make it an array and use hairButtons[1] to index them.
1 Like
Katrist
(Katrist)
September 4, 2023, 8:58pm
#5
You can’t. Just use an array like @txcIove said.
Code:
local hairButtons = {
hairScrollingFrame:WaitForChild('ViewportFrame1'),
hairScrollingFrame:WaitForChild('ViewportFrame2'),
hairScrollingFrame:WaitForChild('ViewportFrame3'),
hairScrollingFrame:WaitForChild('ViewportFrame4'),
hairScrollingFrame:WaitForChild('ViewportFrame5'),
hairScrollingFrame:WaitForChild('ViewportFrame6')
}
for i, button in ipairs(hairButtons) do
print("Key:", "hair".. i, "Button:", button)
end
I need to identify each index later though. Rip I’ll just add numbers to their names and do a search.
or why not just setting the index like [“hair1”] and so on then using:
You can actually just call :lower() or string.lower() on the variable (a) and (b) to compare them with their ASCII values. I tested it myself and it worked.
table.sort(tbl, function(a,b)
return a:lower() < b:lower()
end)
for i,v in pairs(tbl) do
print(v)
end
Output: a, B, c
on the index
Katrist
(Katrist)
September 5, 2023, 1:07am
#8
That only works on arrays. You won’t be able to sort indices.
1 Like