How script works