Hello, I have this script where basically when "Q" is pressed. It'll print something in the output. However, I couldn't seem to make it work. It is a serverscript that is located in ServerScriptService.
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:connect(function(keyCode)
if keyCode.keyCode == Enum.KeyCode.Q then
print("left slot activated")
end
end)
I've checked my capitalisation as well as spelling. When "Q" is pressed nothing seems to print. There is also no output or any errors or warnings. How would this script be altered for it to work and what is causing it to fail?

3 comments
P.S. Use :Connect() over :connect(), always avoid using deprecated methods!
Thanks! May you explain what a "deprecated method" is and how I could avoid them? I'm guessing they are outdated or abandoned methods? Explain if you have time (I'm a new player to studio).
You got it, deprecated methods are methods that have been left in favour to other methods. In Roblox, these are usually just changed concerning cases for uniformity but, deprecated methods might (or at all) not be updated as opposed to their counterparts. It's good practice to avoid them!