Play sound in local area when client pushes a key.

I would like a script that when a client pushes the key “P” on their keyboard it will play a sound in the local area.
I tried to start on the script and this is what I got.

function myfunc()
resource.AddFile(“sound/mango.wav”)
if input.IsKeyDown(KEY_P) && old != input.IsKeyDown(KEY_P) then
sound.PlayFile( “sound/mango.wav”, “”, function( station )
if ( IsValid( station ) ) then station:Play() end
end )
end
old = input.IsKeyDown(KEY_P)
end
hook.Add(“Think”,“efefefef”,myfunc)

It works but it spams the console with a hook error. So i tried to remove the hook but then it didn’t work at all. All it needs is to play a sound at the local area of the client. The sound is mango.wav in the sound folder.

Thanks

Tab your code also put it in code tags. REading it makes me want to scratch all my skin off then burn it

Maybe the actual error would be useful?

You shouldn’t be calling resource.addfile in think hook. No idea if thats the problem as we dont know the error.