Best way to sync AudioTimePosition to an event?

I’m making a game intro solely depending on a music’s time position, like almost every 1 second there would be an event such as camera change,gui, animations etc. What is the best way to update locally whenever a certain time stamp arrives?

I do
repeat RenderStepped:wait() until Music.TimePosition > 2

is there a much more accurate way to exactly execute the next line of code on 2 time position? I mean I’m gonna be having so much Codes.

2 Likes

Other than what you already have (excluding RenderStepped, which should only be used for camera and character updates), there really isn’t any other way. One way or the other, at a fundamental level, this is what you’ll need to be using to do something like what you want. Even then, you’ll never have full accuracy and there will always be a small offset, whether noticeable or not.

You may want to invest some time looking into Promises for this case as well. This probably isn’t what you use them for but you can always have a look around and see if that would help. Integrating them into event-based systems to create a time hook is certainly not out of the question.

2 Likes