If it’s an online game that run with JS, you can modify it’s source code with the developer tool of your browser (the inspect element).
Otherwise if it’s a game that you have downloaded, you’ll only have a binary file. In this case you can’t access the source code because you will only access the compiled file (if you have already use a compiled language like C/C++ you know what I mean). In this case, you can use Reverse Engineering to try to understand the code behind the binary data and potentially find a vulnerability. Reverse Engineering is an exciting topic, it’s also very wide and you’ll need a lot of knowledge, but I’m sure you can find some tutorial online and some good books in the libraries.