✓ Accepted answer
It is suggested that you use ROBLOX's newer form of Input by UserInputService.
Make sure that this is being done by a LocalScript & make sure that the LocalScript is in the proper directory (StarterPlayer.StarterCharacterScripts or StarterPlayer.StarterPlayerScripts or StarterGear or StarterGui)
You can learn about UserInputService here: https://developer.roblox.com/en-us/api-reference/class/UserInputService
game:GetService("UserInputService").InputBegan:Connect(function(InputObject,GameProcessedEvent)
if GameProcessedEvent then
return
end
if InputObject.KeyCode == Enum.KeyCode.E then
print("E has been pressed!")
end
end)
while true do
wait()
if game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.E) then
print("E is being held down!")
end
end
2 comments
But how do I make it so I can hold it down and it will print
I've made a second edit so that you can see how.