Assume Mouse is already defined...
Mouse.KeyUp:connect(function(K) if K=="1" then print("Pressed 1") end
I'm actually not using this for printing an output but for a custom tool equip system. Sometimes my tool (or gun is this case) would glitch and once I unequip it(press 1) it would stay in my character and I'd have to press it again for it to go back to Backpack. Is there a more effective way for linking Number buttons?
The UserInputerService
handles keyboard input much more nicely than the KeyDown and KeyUp events.
local uis = game:GetService("UserInputService") --LocalScript uis.InputBegan:connect(function(inst) if inst.KeyCode == Enum.KeyCode.One then print("Pressed 1") end end) uis.InputEnded:connect(function(inst) if inst.KeyCode == Enum.KeyCode.One then print("Released 1") end end)