Play sound when you press a key

How to write in a script so that when you press the letter E, a sound is played in the ogg format? Lua script

You could use intract-sound.

And if key is a key is pressed, trigger an interact-sound event.

I want to add the line to the existing script.
client.lua (143.7 KB)

I dunno where exactly you want the sound to be executed. As it is a client file, you should use:
TriggerServerEvent('InteractSound_SV:PlayOnSource', 0.5, 'demo', 1.0)
In this example demo would be the demo.ogg which has your sound.

If you do not want to rely on another script, you could basically look at the source code of interact-sound and copy whatever you need over to your script? (I have not checked licenses etc. so that’s on you)