Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is UserInputService deprecated or something? Because it's not working when it's supposed to.

Asked by 5 years ago

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?

1 answer

Log in to vote
1
Answered by
vexound 170
5 years ago

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!

0
Thank you! Sensei_Developer 298 — 5y
Ad

Answer this question