local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input, GPE)
if input.KeyCode == Enum.KeyCode.E then
print("hi")
end
end)
Can someone please tell me what is wrong? It gives me no error and no “hi”
It looks good, as luaMensch mentioned, you need to include this inside of a local script only. That’s the only error I could imagine. If you continue getting errors, let us know.
Global scripts aren’t able to read a user’s input or their mouse unless you pass along the data through a FireServer.
Local scripts are able to view information inputted by the user.
UserInputService should be used on the client, since, simply put it, it’s collecting input from the player/client.
The client can be accessed through LocalScripts, which is what you should be using if you aren’t (your code looks fine. If you are already running this on the client then there may be something else in your code which breaks the thread before the event is connected!)
You can find more about roblox’s client-server model, here.