To send a signal from one script to another, we use a method called sendEvent. We’ll set up the code to use this, then handle an error in the next step.
- Create a new line after the one where you created the chestLid variable, still in the else part of your moveChest function.
- Call the .sendEvent() method on the chestLid.
- Give the method an argument (input) of the exact name of the function you made in your chestLidScript to start the opening animation. The easiest way to do this is to copy and paste it from chestLidScript, and then put “ ” double quotes around it.
This means you did the step correctly! The code won’t work right away, because it is possible that the chest lid doesn’t exist. We’ll fix this in the next step.