How do you hide the toolbar and still be able to equip tools?

is there a way to be able to hide the inventory but still have the ability to equip tools?
i tried, but i cant equip tools.

1 Like

You can’t interact with a CoreGui that is disabled. Assuming you set the Backpack to false.
The best way to do this is to use UserInputService and check for the KeyCode and equip the tool for Humanoid without have to equip it from inventory

Something like this:

local Player = game:GetService("Players").LocalPlayer

local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

local UserInputService = game:GetService("UserInputService")

local Debounce = false
local Act = false

wait()
pcall(function()
	game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false) -- Set the Inventory/Backpack to false mean it will turn invisible.
end)

UserInputService.InputBegan:Connect(function(Input, GameProcessedEvent)
	if GameProcessedEvent then return end -- This will prevent the event firing when player type in chat.
	
	local Keycode = Input.KeyCode
	if Keycode == Enum.KeyCode.One then -- The 1 on the keyboard.
		if not Debounce then
			Debounce = true
			if not Act then
				Act = true
				Humanoid:EquipTool(Player.Backpack.YOURTOOLNAME) -- Equip a specified tool
			else
				Act = false
				Humanoid:UnequipTools() -- Unequip all tools
			end
			Debounce = false
		end
	end
end)

If you want a Custom UI Inventory that can be switched from items to items then it’s way more complicated. You can take a look at this tutorial if you wish to learn something from it:

3 Likes

is the script in startergui?
idk probably
i know its a localscript because it says “localplayer”

You can put it in StarterPlayerScripts.

ok thanks for that
ill try and make it automatically equip

is there a way to be able to equip other tools when you press a gui button?

also, when you die the script breaks and you cant equip tools

You need to make a Custom Hotbar and Inventory for that. It’s way more complicated. But there are tons of tutorials out there showing how to do it.

And also I forgot to mention this: When you die and respawn, all tools will be cleared out.
No wondering why the script breaks because it can’t find the tool.

That’s why you need to put it in StarterGear rather than StarterPack.
Put your tool in ReplicatedStorage and make a PlayerAdded event to detect when a player join, you can make a server script to clone the desired tool in ReplicatedStorage to their StarterGear.
It will automatically put in Player’s Backpack whether if they die or not.

Example:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

Players.PlayerAdded:Connect(function(Player)
	local Clone = ReplicatedStorage.YOURTOOLNAME:Clone()
	Clone.Parent = Player.StarterGear
end)

is that a localscript?
can roblox just remove the 30 [REDACTED] minimum for posts?

Put it in ServerScriptService.
Also it’s a normal script not local script.

ok thanks

uhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

do i remove the first script???

You meant the script handling the UserInputService? No, keep it. Don’t remove.

ok

im guessing the:

local Player = game:GetService("Players").LocalPlayer

local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

local UserInputService = game:GetService("UserInputService")

local Debounce = false
local Act = false

wait()
pcall(function()
	game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false) -- Set the Inventory/Backpack to false mean it will turn invisible.
end)

UserInputService.InputBegan:Connect(function(Input, GameProcessedEvent)
	if GameProcessedEvent then return end -- This will prevent the event firing when player type in chat.

	local Keycode = Input.KeyCode
	if Keycode == Enum.KeyCode.One then -- The 1 on the keyboard.
		if not Debounce then
			Debounce = true
			if not Act then
				Act = true
				Humanoid:EquipTool(Player.Backpack["M16"]) -- Equip a specified tool
			else
				Act = false
				Humanoid:UnequipTools() -- Unequip all tools
			end
			Debounce = false
		end
	end
end)
UserInputService.InputBegan:Connect(function(Input, GameProcessedEvent)
	if GameProcessedEvent then return end -- This will prevent the event firing when player type in chat.

	local Keycode = Input.KeyCode
	if Keycode == Enum.KeyCode.Two then -- The 1 on the keyboard.
		if not Debounce then
			Debounce = true
			if not Act then
				Act = true
				Humanoid:EquipTool(Player.Backpack["M9"]) -- Equip a specified tool
			else
				Act = false
				Humanoid:UnequipTools() -- Unequip all tools
			end
			Debounce = false
		end
	end
end)

and yes i did add another gun thing

Don’t add 2 event listeners like that. It’s bad practice.
You can use elseif statement for another KeyCode firing.
Example:

if Keycode == Enum.KeyCode.One then -- The 1 on the keyboard.
		if not Debounce then
			Debounce = true
			if not Act then
				Act = true
				Humanoid:EquipTool(Player.Backpack["M16"]) -- Equip a specified tool
			else
				Act = false
				Humanoid:UnequipTools() -- Unequip all tools
			end
			Debounce = false
		end
elseif Keycode == Enum.KeyCode.Two then -- The 2 on the keyboard.
      -- Code here
end

This is a list of all KeyCodes if you want to look for it.

Also if you want it to be switched between items then go look at this post!

ok ill try that

aaaaaaaaaaaaaaaaaa LET ME POST

in that other post, do i have to add the names of each of the tools in they keybinds?

uuhhhhhhhhhhhhhhhhhh u there???

what ended up happening? Did u find a fix?!