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

Arrange the order of the tools in a player's backpack?

Is there a way to set the order of the tools in a player's backpack via a script?

4 comments

0

You didn’t specify how you want the tools to be sorted. By name? Type? Damage?

0

If you’re going to ask a question on this website, I’d expect some effort put into the question so I know what you’re looking for

0

What have you tried already.?

0

the question is clear, do you have any constructive info to offer on the matter, T0XN

2 answers

✓ Accepted answer

Tools are sorted by the order they arrive to the backpack, then manually if chosen. So your best option would be to remove all tools then instantly parent them back in the order you want. For example, alphabetical order:

local tools = player.Backpack:GetChildren()
for _,v in ipairs(player.Character:GetChildren()) do
	if v.ClassName=="Tool" then
		tools[#tools+1]=v
	end
end
table.sort(tools,function(a,b) return a.Name<b.Name end)
for _,t in ipairs(tools) do t.Parent=nil end
wait()
for _,t in ipairs(tools) do t.Parent=player.Backpack end

For anything better you gotta make a custom backpack

1 comment

0

Thanks!

I would like to know too if there is a good way.

But yeah, all I can think of, is to remove all items and add them one by one in the order you want. :P

3 comments

0

Why would you put this as an answer then?

0

because it sets the order of the tools in a player's backpack via a script. why would you put this as a comment?

0

You could probably GetChildren() the backpack, .Parent=nil the tools, sort the table with table.sort and then parent them back.

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