Yes, that's clear, I just need the script to generate the key.
However, I suspect that not everything is clear, so I'll provide a script outline with explanations.
function RedKeyFF (heroname)
Trigger(REGION_ENTER_AND_STOP_TRIGGER,"RedKeyF", nil);
MessageBox("/Maps/SingleMissions/Your_Map_Name/RedKey.txt");
GiveBorderguardKey(PLAYER_1,RED_KEY);
end;
Trigger (REGION_ENTER_AND_STOP_TRIGGER, "RedKeyF","RedKeyFF" );
where - heroname (the name of a random hero (you can replace it with the name of a scripted hero, in which case the script will only work with that hero)).
When your hero enters the region named RedKeyF, a trigger is activated, which launches the function (function RedKeyFF), a message RedKey.txt is displayed (with approximately the following content - "The guards, after conferring, decided to give you the keys to the red gate"), and, in fact, the key to the Red Gate is given.