How do I script Ai to make it chase and attack the actor

I would like to know how to script the Ai of my game to chase and attack the main character

There are many ways that this could be done,

For example (Using Simple Blueprint Events and Functions):

you could have a simple blueprint solution in which, inside the AI character’s blueprint you could simply OnEventTick check for the location of the player and call an AIMoveTo event,
in which you provide the AI pawn as the Pawn reference, the location of the Player as the Destination vector, and the Player actor as the Target actor.

Afterwards it would be as simple as checking the distance between the pawn and the player, and if within acceptable distance, apply damage to the player alongside playing an attack animation if desired.