Well, first it depends on the console you are using. For example: now-a-days if you are using PC you can use the Xeno64 injector with a .dll file. If you have XBOX / PS you need a modded console. I'd suggest you learn the language of mod menus on GTA V which I believe in C++. Start there, analyze the code of trainers if possible, and try it yourself.