I am currently in the process of making a custom inventory UI and handler. Now, just as with the normal system by Roblox, you can press the number keys (1-5) and also click on the button directly.
Currently, however, all keys 1-4 work, but when I attempt to push the 5 key it doesn’t do anything. If I click on the 5th button though it works just as intended, only the keybind isn’t working.
I’ve already tried using the key 6 instead of 5 and that works perfectly fine, but after changing it back it no longer works and I have no idea why this is. Here is the code handling the input below:
local Numbers = {['Enum.KeyCode.One'] = 1, ['Enum.KeyCode.Two'] = 2, ['Enum.KeyCode.Three'] = 3, ['Enum.KeyCode.Four'] = 4, ['Enum.KeyCode.Five'] = 5}
-- ...
UserInputService.InputBegan:Connect(function(Input, GameProcessedEvent)
if GameProcessedEvent then return end
if Input.KeyCode == Enum.KeyCode.One or Input.KeyCode == Enum.KeyCode.Two or Input.KeyCode == Enum.KeyCode.Three or Input.KeyCode == Enum.KeyCode.Four or Input.KeyCode == Enum.KeyCode.Five then
for _, ItemSlot in pairs(ItemFrame) do
if ItemSlot.Name == 'InventoryButton' .. Numbers[tostring(Input.KeyCode)] then
local LinkedTool = ItemSlot:GetAttribute('LinkedTool')
print(tostring(Tools[LinkedTool]))
local Corners = ItemSlot.Corners
EquipItem(Tools[LinkedTool], Corners)
end
end
end
end)
As said before it works perfectly fine if I change Enum.KeyCode.Five
to Enum.KeyCode.Six
in the Numbers
table and Input.KeyCode == Enum.KeyCode.Five
to Input.KeyCode == Enum.KeyCode.Six
in the if statement. There are also absolutely no errors whatsoever.
Does anyone know why this is happening?