zombies attack

how can i make a script when i want the zomies to attack when they see the player ?

sorry my englis terrible

Your question is fine. But you provided no attempt to solve this yourself.

In game development this is called AI(Artificial Intelligence). A popular approach is to make a Finite State Machine(FSM). As the name says its Finite(Limited) State(Behavior) Machine(Automation).

In this FSM you would define your various behaviors. Example: Idle, Searching, Following, Attacking. Where the AI could only be in one state at a time.

Now to actually define the behavior’s that is up to you. You can use Raycasting, OverlapSphere(Good for checking “view angles”), Vector math to get distances from target from the AI, etc. Its not something that is super simple.

Either way no one is going to simply write your script for you. So attempt them ask a question.

ermmm…

if (lookatdistance > distance) {
attack()
}

after this, the attack behavior is up to you, because there are ohhhh soooo many ways you could go with AI.