Build Failure/Script Issue

Hi… I’ve encountered a problem running Export & Build (production), whereby I’m presented with a notification (screenshot attached).

If I opt to ‘continue’ I’m unable to get a successful build. If I opt to ‘abort and fix errors’ I’m unsure what to do.

The message at the foot of the window tells me, “Pre-build hook failed. See console for errors” and the console tells me “src/scripts/play.ts(6,4): error TS2564: Property ‘timeline’ has no initializer and is not definitely assigned in the constructor.”

The script referred to is as follows:-

export class Play extends Behaviour
   timeline : PlayableDirector;

Thanks in advance for any advice/how to fix 🙂

[Original Post on Discord](

*by user 908977119781060648*

You can fix it by changing the the timeline line to timeline? : PlayableDirector

And later down the line in change it to this.timeline?.play()

The questionmark is like saying you are not sure if the timeline is assigned. You could also change it to a ! telling typescript that you know for sure its assigned.

Without it typescript will complain that you declare the field (timeline) but its not assigned in the code and typescript doesnt know that it is assigned from unity so it throws an error.

Thanks @marcel :cactus: :+1:

by user 908977119781060648

Quick update… the changes are in place and work perfectly. Big thanks :smiling_face_with_three_hearts:

by user 908977119781060648