How do I create pedestrians that seem like they are randomly walking around in a city

I’m trying to make a Grand theft Auto type city with city life. For now, how do I make pedestrians that walk around and if the player walks into them the pedestrian will say something to them or if they here gunshots the pedestrians will run away?

What you are trying to achieve is actually a quite complex thing.

Your pedestrians would need three states:

1: Wandering around
You could use a navmesh in combination with waypoints here. But for switching from one wp to another you need some python.

2: Fleeing
This could be done with a simple steering actuator triggered by a “hit” message or a collision with your projectile.

3: Talking
I would recommend to use python here too.
Trigger the script with a collision sensor.
In the script create a list of sentences and choose one randomly. You could then send a message to a textobject in you interface to display the sentence.

Managing resources could also be a challenge here as well.

If you’re going to have a bunch of pedestrians on screen at once all running their own logic, you’ll need an effective way of controlling how many can exist at once, when to add and remove them, and maybe even changing their LOD depending on how far away you want them to be visible.