Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Syncing background music in different areas?

Hello so for my upcoming game I've created a lot of original music for it. Since each level in the game has different zones/areas I have created a system in which the music slowly becomes more intense as the level goes on. What I mean by this is that more and more instruments/sounds are stacked on top of each other as the player progress through the level.

This is done by uploading the different parts or instruments of the track into smaller clips which then can be looped. Then as the player progresses, they will hit several triggers which then plays the music.

The system does play the sounds when you enter the areas but there is a slight problem. The music doesn't sync up with each other. The only solution I could think of is to have a timer that goes down as the loop is playing. Since the music and loops all share the same length is shouldn't be that hard in my opinion. I just haven't come up with a way to do it.

Here is the script for one of the triggers. It's pretty simple but hey it works.

function onTouched(hit)
	workspace.Music.Drums:Play()
end

script.Parent.Touched:Connect(onTouched)

2 comments

0

Don’t set the Playing property to true, use the :Play() method provided by the Sound Object class.

0

Yeah sorry i know i about it it's just meant to demonstrate the way it works. I'll edit it

1 answer

What if you paly all the parts of the song at the start, but have all but the first part with a volume of 0, then turn up the volume of the parts you want to now play with your triggers.

script.Parent.Touched:Connect(function(hit)
	workspace.Music.Drums.Volume =1
end)

You could even fade the different parts in and out!

script.Parent.Touched:Connect(function(hit)
	for Vol =0,1,0.1 do
		workspace.Music.Drums.Volume =Vol
		wait(0.05)
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.