Search code examples
luaroblox

Roblox lua UserInputService not displaying anything? possibily outdated. TheDevKing tutorial


UserInputService=game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
    if input.KeyCode==Enum.KeyCode.A then
        print("U pressed A")
    end
end)

My code is above. Is anything wrong with it, because it doesn't display anything?

Putting local before userinputservice

Print out "U pressed A"


Solution

  • Resource: https://devforum.roblox.com/t/userinputservice-not-working/1278104/2

    "UserInputService" is supposed to be used in local scripts, not in server scripts. Try writing your script in a LocalScript inside of StarterPlayer->StarterPlayerScripts.