Auto focus needs some light to work. Your D5000 has a built-in AF Assist light, or as mentioned you can use a flashlight or any other light. (Pages 55, 155, and 197 of the D5000 user manual)
How much light (the detection range) the Nikon Multi-CAM 1000 auto focus module in your D5000 needs to auto focus is noted in the cameras specifications: -1 EV to +19 EV (ISO 100 20°C/68°F). (Page 226 of the D5000 user manual)
If the dark scene you want to shoot has close to or less than -1 EV of light AF won't work.
If the
In Focus indicator in the camera viewfinder is blinking AF can't focus. (Page 31 of the D5000 user manual)
There are 2 AF priority modes - focus priority and shutter priority.
Focus Priority means the shutter will only release if the camera has determined that focus has been achieved.
This is what you are experiencing.Tthe scene is so dark focus is
not being achieved, so even though you press the shutter release button - the shutter does not release and nothing happens.
Focus priority is set when AF-S (Single focus) is the focus mode the camera is set to.
Shutter priority means the shutter will release every time the shutter release button is pressed
regardless if focus has or has not been achieved.
AF-C (Continuous focus) is a shutter priority AF mode.
Your D5000 has 3 auto focus modes and 4 auto focus area modes to choose from.
If you want to become better acquainted with the focus options your camera has refer to the D5000 User Manual pages 54 - 61. The complete user manual is a PDF file on the software disc that came with the camera. If you don't have the software disc you can download the D5000 user manual at -
https://support.nikonusa.com/app/answers/detail/a_id/13948