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
{
   @serializable(PlayableDirector)
   timeline : PlayableDirector;
    
    update(){
        if(this.context.input.getPointerDown(0)) this.timeline.play();
        
    }
}```

Thanks in advance for any advice/how to fix 🙂
![00.jpg](https://cdn.discordapp.com/attachments/1075448621736136756/1075448622310752256/00.jpg?ex=65d62014&is=65c3ab14&hm=dafbd9c1ebf815b81f3f3736bbda9e6ffbb93d4618c8d4a7ea9ded1fd5a9bf18&)

[Original Post on Discord](https://discord.com/channels/717429793926283276/1075448621736136756)

*by user 908977119781060648*

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

And later down the line in timeline.play 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