# This is our main script. It connects the button to the box. # We call this a "Script" because it gives instructions. # First, we need to find our devices. # We will look for them by their names in the editor. my_button := ButtonDevice:Find("MyButton") my_box := CubeProp:Find("MyBox") # This function runs when the game starts. Initialize <- (): void => # We tell the button to watch for clicks. # When it clicks, it will run the "OnButtonPressed" function. my_button.InteractedWithEvent.Subscribe(OnButtonPressed) # This function runs ONLY when the button is pressed. OnButtonPressed <- (event): void => # We find the box by its name. box_to_change := CubeProp:Find("MyBox") # If we found the box, let's change its color! if (box_to_change != None): # We set the color to bright green. box_to_change.SetColor(Color(0.0, 1.0, 0.0)) # Optional: Print a message to the console to help us debug. Print("Button pressed! The box is now green.")