I’m tryna track when a player presses a number on their keyboard, so I can move their selected inventory slot. However, I want to make this as efficient as possible
local UserInputService = game:GetService('UserInputService')
local Frame = script.Parent
local CurrentSelected = Frame['1']
local function changeSelected(selected)
CurrentSelected.Backing.ImageColor3 = Color3.fromRGB(200, 200, 200)
CurrentSelected = selected
CurrentSelected.Backing.ImageColor3 = Color3.fromRGB(0, 170, 255)
end
for _, v in pairs(Frame:GetChildren()) do
if v:IsA('ImageButton') then
v.Activated:Connect(function()
changeSelected(v)
end)
end
end
UserInputService.InputBegan:Connect(function(input, GPE)
if GPE then return end
if input.UserInputType == Enum.UserInputType.Keyboard then
end
end)
When I print(input.KeyCode) it returns an Enum, as well as the number being ‘One’, ‘Two’ etc. However, my inventories buttons are labelled ‘1’, ‘2’, etc. I got it working with clicking on the individual buttons, I want numbers to work as well