Welcome to the forums. What phone do you have and which android version is it running? You could try this. Go to settings - sounds & notifications - app notification - select your text messages app and switch 'allow peeking' off.
As the learned Javier said. All devices have multiple options regarding notifying you, but to help you accurately, we need device and software minimum.