Roy's dismissal sparked the South Africa fightback, however.
Tom Curran holed out before Moeen Ali was bowled by Lungi Ngidi, which left England needing two from the last ball, and Adil Rashid was run out coming back for the second as South Africa drew first blood in the three-match series.
Roy had seemingly left England in a promising position following an innings containing seven fours and three sixes but they, like South Africa before them, found scoring increasingly difficult as the innings progressed.
Having been 105 for one at the halfway stage of their innings, South Africa settled for 177 for eight in a total where Moeen collected one for 22 and Rashid took one for 23, with Chris Jordan taking two wickets in the last over.
Additional reporting from Press Association