At the top of your script add
Set Error Capture [On]
This means that you, the developer, will capture the errors and take care of them. FileMaker will not give the error message you're currently seeing.
Hope that helps.
You missed the script step:
Set ErrorCapture [on]
That will suppress the default popup and let you control things yourself...
Also, if the number of records in your found set is a few hundred or more, consider performing this script on the server using Perform Script on Server. It'll be much faster.
You'll have to call Perform Script on Server (PSOS) as a sub-routine. Simply create a new script with the script step PSOS and call "Unflag All".
If your script "Unflag All" is triggered by a button for event, switch that over to the new script.
All of this, of course, presumes you have FileMaker Server.
Note: PSoS acts like a new user opening the file. It runs the Script Trigger on FirstWindowOpen. You must be sure to establish the context and found set within the script and DO NOT rely on anything in the current user's session.
Yes, ch0c0halic is correct.
In my solutions I have a server privilege set (e.g. "FMServerUser") and in the opening script check to see if FMServerUser is the one opening the file. If so, I exit the opening script as soon as possible (but after any required settings such as global fields, global variables, etc.).
The other thing to do to explicitly set the context. Modify your script by adding "Go to Layout..." so the server knows where to go. Again, as ch0c0halic points out, the server's session is different than yours, so it won't know anything about what layout the user has open.
Lastly, use the "Show compatible script steps by button" in the upper right of the Script Workspace in FM 14. Script steps such as "Show custom dialog" are incompatible and will produce an error. If you run it on the server (PSOS), you won't need this or other non-server compatible steps, so you can delete them.