Implement lock for scripts.
Add example script with lock use