well Custom Scripts are just short peaces of the "real"code; the "compiler" (dont know if its the correct english word) will translate the GUI script into the scripted jass and than write the map script.
So long:local player p will create a local variable, wich can only be used in the function (sometimes = trigger) that they are defined in.
= GetOwningPlayer(GetTriggerUnit()) will set it equal to the Player, that owns the Triggering Unit, that means the Training barracks or what ever.
Because of the wait, we need this local. Whil the trigger "sleeps" during a wait, the global variable player could be overwritten again(if u want to use it somewhere else f.e.), A local variable can only be overwritten in the function that its defined in, so u can use a wait and u dont have to fear losing data.
Oh i detected a mistake! SRY ^^, logically it should be set udg_player = p
So Custom script: set udg_player = p sets the global var equal to ur stored player in p. This is nessecary to use the GUI.
Custom script: set p = null removes leaks, as u wont need the var p anymore, after Trigger is finished.
Please correct me if i explained something wrong
Greets