To delete an 'undo' event from a script you need to delete both the 'undo', and the stroke before it which you undid while recording.
Look through your script for a line similar to this:
Wait: 2.439s EvType: Command CommandID: Undo
That is the actual undo event. (The Wait: time will be different in yours)
Just above the 'undo' command you will find whatever it is you're undoing. If it's a stroke of paint you will see a block of stroke points looking something like this
Code:
<StrokeEvent>
<StrokeHeader>
<EventPt> Wait: 0.697s Loc: (652, 446) Pr: 0.75 Ti: 1 Ro: 0 Fw: 1 Bt: 0 Rv: NO Iv: NO </EventPt>
<Recorded> Yes </Recorded>
<RandSeed> 0x000000002, 0x000000000 </RandSeed>
<Smooth> Count: 3
Loc: (639, 446) Pr: 0.75 Ti: 1 Ro: 0 Fw: 1 Bt: 0
Loc: (632, 446) Pr: 0.75 Ti: 1 Ro: 0 Fw: 1 Bt: 0
Loc: (627, 446) Pr: 0.75 Ti: 1 Ro: 0 Fw: 1 Bt: 0
</Smooth>
<PrevA> Loc: (697.083, 344.894) Pr: 0.75 Ti: 1 Ro: 0 Fw: 1 Bt: 0 </PrevA>
<PrevB> Loc: (695.167, 344.788) Pr: 0.75 Ti: 1 Ro: 0 Fw: 1 Bt: 0 </PrevB>
<OldHd> Loc: (632, 446) Pr: 0 Ti: 1 Ro: 0 Fw: 1 Bt: 0 Dr: (0.438983, -0.898495) Hd: (0.898495, 0.438983) </OldHd>
<NewHd> Loc: (639, 446) Pr: 0 Ti: 1 Ro: 0 Fw: 1 Bt: 0 Dr: (0.825467, -0.56445) Hd: (0.56445, 0.825467) </NewHd>
</StrokeHeader>
Wait: 0.000s Loc: (663.5, 449) Pr: 0.75 Ti: 1 Ro: 0 Fw: 1 Bt: 0 Rv: NO Iv: NO
Wait: 0.018s Loc: (678.25, 456) Pr: 0.75 Ti: 1 Ro: 0 Fw: 1 Bt: 0 Rv: NO Iv: NO
Wait: 0.018s Loc: (690.125, 464.5) Pr: 0.75 Ti: 1 Ro: 0 Fw: 1 Bt: 0 Rv: NO Iv: NO
</StrokeEvent>
You will need to delete that entire block.
It's possible it was some other event instead of a stroke - you will need to delete whatever command or block precedes the 'undo' event. Note that if there's more than one 'undo', you will need to delete more than one previous event. If there is a 'redo' after the 'undo' then you can just delete the 'undo' and 'redo', as they cancel each other out.