Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How is table.sort used? attempt to compare two userdata values?

1 answer

✓ Accepted answer

You're trying to sort objects with this - table.sort() only works with strings.

You'll have to convert it to strings, with something like the code below:

t = game.ReplicatedStorage.Stuff:GetChildren()
local newTable = {}
for i = 1, #t do
	table.insert(newTable, 1, t[i].Name)
end
table.sort(t)
print(table.concat(t, ' '))

This discussion is preserved as it was. New answers, comments, and votes are closed.