Move tools inside backpack box

Hi, I was wondering if it’s possible to move tools via a script to the backpack box.

Unfortunatly, you can’t easily manipulate where exactly tools go in your backpack. Corescripts, and the user control where icons appear, not your scripts. The only solution would be to make your own inventory/hotbar system so then you can manipulate anything you want with it.

In fact, you can! The count of tools in a player’s backpack increases every time a tool is cloned. Suppose we first copy 10 tools into the player’s backpack, which is the max bar, then copy the tool you want to give, and then delete the rest.

Here’s how it works!

local function ManipulateToolKeyNumber(Player,ToolYouWantToClone)
	local ToolTable = {}
	for i = 0,10,1 do -- make 10 tools
		local Tool = Instance.new("Tool",Player.Backpack)
		ToolTable[i] = Tool
	end
	ToolYouWantToClone.Parent = Player.Backpack -- copy the tool in the backpack
	wait()
	for i,v in pairs(ToolTable) do
		v:Destroy() -- delete all 10 tools that we cloned first
	end
end

game.Players.PlayerAdded:Connect(function(Player)
	wait(5)
	ManipulateToolKeyNumber(Player,script.Cola:Clone()) -- script.Cola:Clone() is going the be the tool you want to clone
end)

I would appreciate it if you could give this a check! :white_check_mark:

I guess this works, but it is very hacky. Theres no way to detect which tools are in the hotbar, or which tools are in the backpack already. This code will most likely mess up if tools are already in the backpack.

That’s not accurate. Of course you can detect how many tools are in the backpack. We can detect if there are already 10 tools in the backpack if we want the tool to be in the backpack without breaking the number.

local function ManipulateToolKeyNumber(Player,ToolYouWantToClone)
	local ToolTable = {}
	
	local HowManyToolsAreThereInBackpack = #Player.Backpack:GetChildren()
	local i = 0
	
	if HowManyToolsAreThereInBackpack > 10 then
		print("Already 10 tools in backpack")
	else
		repeat -- make remaining tools
			i += 1
			local Tool = Instance.new("Tool",Player.Backpack)
			ToolTable[i] = Tool
			print("DONE")
		until #Player.Backpack:GetChildren() == 10
	end
	
	ToolYouWantToClone.Parent = Player.Backpack -- copy the tool in the backpack
	wait()
	for i,v in pairs(ToolTable) do
		v:Destroy() -- delete all 10 tools that we cloned first
	end
end

game.Players.PlayerAdded:Connect(function(Player)
	wait(5)
	ManipulateToolKeyNumber(Player,script.Cola:Clone()) -- script.Cola:Clone() is going the be the tool you want to clone
end)

I’m talking about that hidden menu with extra tools, that you have to press [`] to open. You can’t tell the difference between which tools are in that, and which are on the hotbar- which are always visible.

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