I worked on that, with custom melee AI. And I'm gonna be honest with you, it's unnecessarily complicated.
1/ You MUST change the AI race BEFORE you start the AI script (whether melee or campaign). You can change it to a custom race.
2/ The melee AI script knows ONLY the default ones, that is to say, for the default 3 races. If the race is a custom race (chosen from the game salon of in your player properties), the AI script won't work. Why ? Because it's native and it has entries for the AI galaxy scripts like the function "TerranInit". No fun allowed. In the debugger, you can see some in the tab "Internal Calls".
3/ So you MUST allow Terran, Zerg or Protoss only from the game salon or your player properties !
4/ Do NOT change it after it started. You will break it for similar reasons as 2/.
0.887412115958779