How should i sync all these sounds?

Im making a DS style gui selection thingy for my game, and i made music for all the tabs. how would i sync it, so it transitions to the next song when i select a new tab?

(They are all the same format, speed, BPM, and length, just different versions.)

local Set = script.Setting
local Main = script.Main
local Find = script.Finder
local Dame = script["D-Name"]

local event = game.ReplicatedStorage.CwindowChanger

event.Event:Connect(function(Wind)
	if Wind == "Main" then
		Main:Play()
		
		Set:Stop()
		Find:Stop()
		Dame:Stop()
	end
	
	if Wind == "Set" then
		Set:Play()
		
		Find:Stop()
		Dame:Stop()
		Main:Stop()
	end
	
	if Wind == "Find" then
		Find:Play()
		
		Main:Stop()
		Set:Stop()
		Dame:Stop()
	end
	
	if Wind == "Disp" then
		Dame:Play()
		
		Main:Stop()
		Set:Stop()
		Find:Stop()
	end
	
	
	if Wind == "None" then
		Main:Stop()
		Set:Stop()
		Find:Stop()
		Dame:Stop()
	end
end)
1 Like

For now, it justkinda starts p[laying the next one from the beginning, but i wanna know how i could make it continue from the last selected song? Like sync them all up

i guess you want to do a crossfade?
tween the volume

to get them all synced correctly you should play them all at the same time. then when you switch your screen. use the volume property to either fade between them.

No like, i dont wan it to play from the beggining, i want it to continue from the last song.

Like one song is 20 seconds in, i wanna be able to switch to the next, but play it starting 20 seconds in

How would i play them at the same tme? because they will load at diffrent times, so how would i play them at the same exact time?

if that’s still not synced set the TimePosition property to the TimePosition property of the current playing audio

then you gotta use TimePosition i guess

oh. So I would assume they are playing on game start. in that case I would wait for all of them to be loaded before playing them. you can do this by looping through them and checking if the IsLoaded property is true

I found a semi-solution that works decently

local Set = script.Setting
local Main = script.Main
local Find = script.Finder
local Dame = script["D-Name"]

local event = game.ReplicatedStorage.CwindowChanger

local Time = 0

event.Event:Connect(function(Wind)
	if Wind == "Main" then
		Main:Play()
		Main.TimePosition = Time
		
		Set:Stop()
		Find:Stop()
		Dame:Stop()
	end
	
	if Wind == "Set" then
		Set:Play()
		Set.TimePosition = Time
		
		Find:Stop()
		Dame:Stop()
		Main:Stop()
	end
	
	if Wind == "Find" then
		Find:Play()
		Find.TimePosition = Time
		
		Main:Stop()
		Set:Stop()
		Dame:Stop()
	end
	
	if Wind == "Disp" then
		Dame:Play()
		Dame.TimePosition = Time
		
		Main:Stop()
		Set:Stop()
		Find:Stop()
	end
	
	
	if Wind == "None" then
		Main:Stop()
		Set:Stop()
		Find:Stop()
		Dame:Stop()
	end
end)

local run = game:GetService("RunService")

run.Heartbeat:Connect(function()
	if Main.Playing then
		Time = Main.TimePosition
	elseif Set.Playing then
		Time = Set.TimePosition
	elseif Find.Playing then
		Time = Find.TimePosition
	elseif Dame.Playing then
		Time = Dame.TimePosition
	end
end)

Only issue, when i switch theres like a second of no sound, then it cuts back to the music. any ideas to fix this?

The second of no sound is probably because the sounds havent loaded

no like event when i switch back to sounds that i already loaded

Found another partial, working better solution, that is controlling volume instead of :play() or :stop()

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.