What I want to do is use the # keys on the keyboard to trigger certain scripts. (Preferably 2 in this case)
local mouse = game.Players.LocalPlayer:GetMouse() local emp = false function getTool() for _, kid in ipairs(script.Parent:GetChildren()) do if kid.className == "Tool" then return kid end end return nil end mouse.KeyDown:connect(function (key) -- Run function if key == "2" then <---[[PROBLEM RIGHT HERE. I want this to be 2, it works with "q", but I need numbers, not letters]] emp = true print("EMPon") local character = script.Parent local player = game.Players:GetPlayerFromCharacter(character) player.EMPon = true if player.EMPon == true then EMPvictim = player.EMPvictim repeat wait() until EMPvictim.Value ~= nil victim = game.Players:FindFirstChild(""..EMPvictim.Value) player.PlayerGui.EMP.Adornee = victim end end end)
I believe SetCoreGuiEnabled will allow you to use the number keys if you disable backpack.
Otherwise, try InputBegan
-- Example: game:service'UserInputService'.InputBegan:connect(function(obj) if obj.KeyCode == 'One' and obj.UserInputState == 'Begin' then -- I believe this would work. print'1 was pressed that day.' end end)