Syncing sound with a tween animation

Hey, I wanted to make a case opening system, and tried to sync a sound with the tween animation

My idea is that whenever the gray bar in the middle touches a child of the frame that holds all the images then the sound is played
There is a frame that when I roll theres always a tween animation that plays it to the UIDim2(-2,0,0,0) position, and that frame has the imagelabels inside with a uilist so they stack

Here is an example of what I have now

I tried using absoluteposition so i checked every frame if the absolute position X is the same as the gray bar then play the sound BUT because im tweening the frame to move and not the children the absoluteposition always seem to be 0 (this might seem a terrible idea due to having to check for every imagelabel child every frame)

1 Like

I mean, you could calculate the time it takes for the current speed to pass the general size of the frame, so if your frames size on the X Axis is 50 and the bar is moving 50 pixels a second, then you could say Distance (or the Size on the X Axis)/Speed = Time, and create a delay function using said time and play a sound.

This is assuming you are updating the speed that its going in, and are able to easily access that data, otherwise you can probably use PlayerGui:GetGuiObjectsAtPosition, and check if the overlapping gui is different, to which make a different sound.

2 Likes