Sorry if the title is bad, didn't know how to word it correctly.. but what I'm trying to say is, how do you make a script from Pirate perfection work on your own trainer, for example I could have this in a separate trainer I use, and it would give me the error "warptbullet.lua:7: attempt to call global 'inGame' (a nil value)" and "X-ray.lua:165: cannot use undeclared global 'inGame'" (I know its not the same, but for example its just giving me something to do with the inGame function, and I have no idea how to fix it) Anyone know how to make it work? :c Just for the record, I'm a complete noob at lua.
Code:
function inGame() 
  if not game_state_machine then return false end 
	return string.find(game_state_machine:current_state_name(), "game") 
end 
if inGame() and managers.platform:presence() == "Playing" then
	-- SPAWN AMMOBAG ON SELF
	local pos = managers.player:player_unit():position()
	local rot = managers.player:player_unit():rotation()
	local ammo_upgrade_lvl = managers.player:upgrade_level( "ammo_bag", "ammo_increase" )
	if Network:is_client() then
		managers.network:session():send_to_host( "place_deployable_bag", "AmmoBagBase", pos, rot, ammo_upgrade_lvl )
	else 
		local unit = AmmoBagBase.spawn( pos, rot, ammo_upgrade_lvl )
	end
else
end