Programmed Illusion
You craft an illusory object, creature, or other effect which executes a scripted performance when a specific condition is met within 30 feet of the area. You must describe both the condition and the details of the performance upon casting. The trigger must be based on something that can be seen or heard.
Once the illusion triggers, it runs its performance for up to 5 minutes before it disappears and goes dormant for 10 minutes. The illusion is undetectable until then and only reactivates when the condition is triggered and after the dormant period has passed.
A creature can use an action to attempt an Investigation check against your spell save DC to reveal the spell’s illusory nature. Physical interactions reveal the illusion for what it is as things can pass through it with ease. A creature aware of the illusion perceives the image as transparent and the sounds it generates hollow.