Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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!

1 comment

0

Thank you!

This discussion is preserved as it was. New answers, comments, and votes are closed.