Then I recommend adding a check: if IsAIPlayer(number) then, and only if the statement is true, offer the upgrade.
In short, Azgalor suggested the following:
"Try using GetPlayerFilter(GetCurrentPlayer()) in the MessageBox instead of GetObjectOwner(hero)."
In the end, it worked, thank you both for your help.