That’s how I’d do it, would be best if it’s encrypted in memory as well. Or at least encrypt important values so you can’t edit them with Cheat Engine or similiar programs. There’s also ways to make it harder to debug and reverse engineer your game if you want to look into them
But whatever you do, someone will be cheating sooner or later. No way arround that, you can only slow them down
Only exception is server sided games, but you can still create bots for those and maybe even find some way to exploit your code