Right now the chest lid animation starts as soon as the game loads, which is great for testing, but not the way we want it to work in the end. To fix this, we just need an if-statement and a boolean variable to keep it from going right away.
- Above the start function, create a variable called startAnimation and set it to false.
- In the beginning of the tick function, create a new if-statement whose condition is the value of this.startAnimation
- Move the final } curly bracket to go after all the code in the tick function.
- Indent all that code so that it is clear
Tip: Tab and Shift+Tab
Unlike your normal word editing program, in the script editor, you can select several lines, and press Tab to indent them all one level at once. You can also use Shift+Tab to move the indentation back to the left.