How to disable tool-releasing?

So for my game, I disabled Roblox’s built in inventory UI system, but I still use “Tool” objects to make my life a whole lot easier when it comes to holding and activating items.

local StarterGui = game:GetService('StarterGui')
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)

I now have a problem.
If you press backspace when holding an item in my game, it will put the item inside your backpack.

Is there any easy way to fix this without having to loop tools inside the backpack to go back into the character?
I have tried just deleting the Backpack object, but it seems that a new one is just created when you press backspace.

GAME:

If the “CanBeDropped” property is disabled, I’d personally use the Unequipped function of a tool to put it inside your own inventory system. If that is indeed the case you are doing.

Update: This also works in the case of pressing Backspace.

Example:

local Tool = script.Parent

Tool.Unequipped:Connect(function() 
   wait() --Without this it still puts it in your backpack for some reason.
   Tool.Parent = game:GetService("Lighting") --Puts the tool in Lighting.
end)
2 Likes

Here’s the code I used for my game.

game:GetService("Players").PlayerAdded:connect(function(player)
	local function hookTool(tool)
		if not tool:IsA("Tool") then return end
		game:GetService("RunService").Heartbeat:wait()
		tool.Parent = player.Character
	end
	
	player:WaitForChild("Backpack").ChildAdded:connect(hookTool)
	
	player.ChildAdded:connect(function(child)
		if child:IsA("Backpack") then
			child.ChildAdded:connect(hookTool)
		end
	end)
	
	for i,v in pairs(player.Backpack:GetChildren()) do
		hookTool(v)
	end
end)

Put this in one script (preferably in ServerScriptService) to fix all your tools.

2 Likes

I’m aware the script listed here might be a little old, but if I was you I’d change the :connect(s) in the script to :Connect as :connect is indeed deprecated and shouldn’t be used.

I intentionally use :connect over :Connect even in newer code because I know they’ll always act the exact same, connect will never be removed, and :connect looks better on my eyes than :Connect. Thanks for your concern.

6 Likes