Many games have "surprise" mechanics, which govern specific instances in which PCs or the opponents they are fighting are surprised. If the opponents are surprised, the PCs gain some brief advantage in the opening moves of any ensuing combat. On the other hand, if the PCs are surprised, the opponents get a chance to attack first with various bonuses.
Since it's difficult at best to accurately determine when the players are surprised, and this doesn't necessarily track when their characters are surprised anyway, surprise is often determined somewhat arbitrarily using a dice roll for randomisation, sometimes with modifiers based on traits such as the characters' perception statistics, circumstances such as darkness, and so on.
Or you can just use the tried and true GM technique of simply saying, "You're surprised".
Transcript
GM: You see a couple of banthas.
Adam: What's a bantha?
Captain Antilles: {dead} A spicy desert fruit.
GM: Large riding beasts.
C-3PO: It's Sand People, all right.
Adam: Hmm. Are we talking boss fight or random encounter here?
GM: As you're pondering that, one leaps up and—
Adam: I shoot him!
[SFX]: Hrruuurrgg!!
GM: No, you're surprised.
Adam: I'm really not.
GM: By which I mean, he gets a +4 Ambush bonus. And the first attack.
Adam: Please tell me this game doesn't have Quick Time Events.