Is there a way to disable keycodes on the roblox inventory system?

Alright so I am wondering if there is a way to disable keycodes on the roblox inventory. I am going to go ahead and assume without this disclaimer there would be many people saying “Disable viewing the inventory and make a custom” “Just make a custom inventory”, now I would do that if i had the time but atm i don’t have enough time to do it.

So if you are wondering what I mean, I mean like if you press “1” item 1 pops up. Is there a way to disable you being able to press keys to open items so i am able to do a temporary method of just clicking whatever key you have set in the keybinds.

I would say the Wiki might help, although I didn’t look through the whole thing.

Already did look through that, googled it, googled like 6 different things, went through devforums, nothing

I know there is a way but I can’t remember how.

Are you sure though? I looked through the wiki and googled it, I googled like 6 different things related to it, I even searched through the devforum. Nothing related to it

1 Like

I suppose you could try something like this

mouse = game.Players.LocalPlayer:GetMouse()

mouse.KeyDown:connect(function(key)

if key == "1" or key == "2" then

code here

end

Yes but that wouldn’t disable the original item, if someone pressed 1 on accident but that wasnt even a binded key that would open item 1

You can also take a look at the Core - Script

local GAMEPAD_INPUT_TYPES =
{
	[Enum.UserInputType.Gamepad1] = true;
	[Enum.UserInputType.Gamepad2] = true;
	[Enum.UserInputType.Gamepad3] = true;
	[Enum.UserInputType.Gamepad4] = true;
	[Enum.UserInputType.Gamepad5] = true;
	[Enum.UserInputType.Gamepad6] = true;
	[Enum.UserInputType.Gamepad7] = true;
	[Enum.UserInputType.Gamepad8] = true;
}

You could try setting them to false.

It’s not a matter of unbinding keys so much as it is unequipping the tools as soon as they are equipped. For whatever the reason may be you can’t unbind the number keys so that simply isn’t an option.

Instead opt for a solution that looks a bit like this.

First we need to get all the tools a player has in their inventory when they spawn (tools in starterpack), and then verify that their Class is Tool.

for _,tool in pairs(game.Players.LocalPlayer.Backpack:GetChildren()) do
	if tool:IsA("Tool") then
		tool.Equipped:Connect(function()
			game:GetService("RunService").RenderStepped:Wait()
			game.Players.LocalPlayer.Character.Humanoid:UnequipTools()
		end)
	end
end

Now we need to detect when the tool is equipped, which is as simple as this:

for _,tool in pairs(game.Players.LocalPlayer.Backpack:GetChildren()) do
	if tool:IsA("Tool") then
		tool.Equipped:Connect(function()
			
		end)
	end
end

Lastly, we need to unequip the tool, while also adding in the tiniest weight so that we don’t receive any errors (ex: unknown attempted to set parent)

for _,tool in pairs(game.Players.LocalPlayer.Backpack:GetChildren()) do
	if tool:IsA("Tool") then
		tool.Equipped:Connect(function()
			game:GetService("RunService").RenderStepped:Wait()
			game.Players.LocalPlayer.Character.Humanoid:UnequipTools()
		end)
	end
end

And huzzah, the script is completed!

Very barebones though, if you want to go even further in-depth you can add a sort of “bypass” system that prevents any item from being equipped when a number key is pressed prior - allowing the player to still equip via clicking the hotbar icon, or through a UserInput connection.

1 Like

This script doesn’t work for me because of mobile players and i have my inventory specifically coded to my needs, i dont have anything in starterpack after the player clicks deploy on the main menu it gives them a forcefield for 1 second then takes it away and gives them their weapons

However I kinda get the script but i think it really depends on uip instead of equipped due to how mine works but i get the script, Thanks

The same system can be implemented with, only connecting UnequipTools to 1,2,3 etc instead of to Tool.Equipped.

2 Likes

Yeah ik, Even though it doesn’t look like it because I don’t pay attention to how the inventory system works I can do top level scripting so connecting it to uip is a peace of cake

oh…than idk lol i might have just dreamed it