While I was making a game, I made a ServerScript
inside of a part and wrote:
local function Epress(keyCode) if keyCode.KeyCode == Enum.KeyCode.A then print("A has been pressed") end end game:GetService("UserInputService").InputBegan:Connect(Epress)
However, it didn't work when it was supposed to.
So then, I tried doing it on a LocalScript
inside of the StarterGui
.
Still didn't work.
Help?
Your code works and UIS is not deprecated. I tested it myself too, just be sure that you're using a non disabled local script inside of StarerGui
and that the button you're pressing is the same as the assigned keycode. So in this instance your button is A, so making sure you're pressing the A button.
Also be sure not to use a server script for detecting player input because it's detected on the client side. If you want to go from the client to the server you'll need to use a remote event/function.
Hoped this helped and have a nice day!