Welcome!
I had that problem with my D5100 years ago. Mine was still under warranty so It went in for a repair.
There may be some suggestions in this thread that you might find helpful if you're good at fixing things.
https://nikonites.com/forum/threads/did-my-d5100-run-out-of-film.14326/...