If you're new to Fivem, or even roleplaying in general, it can be a bit overwhelming to some. So hopefully at the end of this guide, you wi be an RP master, or at least decent enough at it to have a good time.
So first things first; what actually is roleplaying. Most new players assume it's just pretending to be someone else. Which is not necessarily true. Roleplaying is getting immersed in the world, and acting like you exist in that plain. You're not pretending to be a police officer, you ARE a police officer. That might sound a bit cringy, which it is. but if we're all cringy together, who cares?
Very import part of roleplaying is correctly acting out your character. Making clear to the other player what your character is doing. You can either say that (still in character) you're going to do something. i.e. "I'll quickly check your engine to see if it's still working". Usually quite effective combined with the in-game emotes. For more complicated actions, that you wouldn't necessarily say out loud, you can use the /me command. i.e. "/me digs under the hood of the car, vigorously looking for the problem".
Whenever you're in an RP situation, always remember you're both there to have fun. RP situations that would be "less enjoyable" in real life, like getting pulled over, or shot, can still be a lot of fun on FiveM. The police isn't against the player, they are there to create situations that can lead to fun experiences.
Note: Random =/= funny. However, acting out a crazy person that does complete random junk, can be fun to roleplay as/ interact with.