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

When hiding the backpack the tools don't work?

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)

i used this to hide/disable the default backpack. I am making my own inventory and when you click the gui for equipping it equips it onto the character. the tools work if the backpack is not hidden.

Would this mean i would have to manipulate the code in the actual tool so it would know when the tool is equipped (true or false boolean) and then if its equipped then whenever i click the screen it would perform whatever the tool does?

Thank you for reading, I want to ask this question to know if there's a more efficient method in doing this.

1 answer

You can manually equip a tool like this:

local Player = game.Players.LocalPlayer
local Character = Player.Character

function EquipTool(toolname)
	for _, v in pairs(Player.Backpack:GetChildren()) do 
		if v:IsA('Tool') and (v.Name == toolname) then 
			DequipTool() -- unequip any other tools
			v.Parent = Character
		end
	end
end

function DequipTools()
	for _, v in pairs (Character:GetChildren()) do 
		if v:IsA('Tool') then 
			v.Parent = Player.Backpack
		end
	end
end

1 comment

0

Thanks but it didnt answer the question i just had to manipulate the code using userinputservice instead of tool.Activated.

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