hello and welcome. for future reference I suggest you use [
code][
/code] tags around your code to make it more readable.
now as for your problem, I'm not too sure exactly what you want this to do, so here is a few questions to help me understand exactly, is it being used in a larger program, or on its own as like a 'mob farm' script? does that mean it is meant to attack and then turn and stop, or continue to attack once turned? if it is meant to keep attacking, does it ever have to stop?
now as an immediate fix. while loops should follow the following format.
while <condition> do
-- your code in here will run while the condition is true
end
where
<condition> should be a boolean or a function call that returns a boolean (such as most turtle functions, check the wiki for more info). Note: A boolean is a variable that is true or false.