why it cant

It says there else without a previous if.but I put an if there

The compiler's verdict is correct

The else is inside the block after if (think about that, flow would only get to the else, if the if condition was true, in which case else would not be execute!)... and inside a for loop too. That is not valid syntax, and as I noted above, is nonsensical as written. Review the syntax for if statements, and keep careful track of {}'s

Also, don't post pictures of text. Use code tags and paste the actual text - it makes it much easier on the people

Also, don't put semicolons after ifs.

I couldnt understand

1) Post code, not pictures of code. 2) an if statement doesn't have a semicolon after it.

thank you

kaan03: It says there else without a previous if.but I put an if there

If you do a Google search on;

'Arduino If'

It points to the Arduino reference for the If command.

The Arduino reference is a good way of checking the structure of commands and researching errors in your code.