Better way of checking instead of using task.wait()

I wanted to know if there’s a better way to do this:
image
as you can see, I’m using task.wait in between each remote fired, but it’s truly not reliable.

when a remote is fired, the specified audio file will play on the client.

–Text Version

zone.playerEntered:Connect(function(player)
	Remotes.SeriousRoom.SeriousRoom_1:FireClient(player)
	task.wait(7.5)
	Remotes.SeriousRoom.SeriousRoom_1_1:FireClient(player)
	task.wait(8.5)
	Remotes.SeriousRoom.SeriousRoom_1_2:FireClient(player)
	task.wait(9.7)
	Remotes.SeriousRoom.SeriousRoom_1_3:FireClient(player)
	task.wait(8.3)
	Remotes.SeriousRoom.SeriousRoom_1_4:FireClient(player)
	task.wait(13.8)
	Remotes.SeriousRoom.SeriousRoom_1_5:FireClient(player)
	task.wait(9.5)
	Remotes.SeriousRoom.SeriousRoom_1_6:FireClient(player)
	task.wait(9.9)
	Remotes.SeriousRoom.SeriousRoom_1_7:FireClient(player)
	task.wait(10.4)
end)

hm, not sure if it would work since I’m looking for something better to use other than task.wait() for the script.

what do you want to achieve exactly?
also you can use an identifying argument in remote events instead of creating a remote event for each sound.

Audio sequences should be handled fully on the client. The client can use methods and events to detect accurately when the track ends and start the next one. The server can’t.

okay so, I’m looking for a better way to possibly check if a sound that’s fired by the remote is playing and if it ended, or just anything to replace task.wait() as I wouldn’t want to be doing that every single time when I make a new “zone”

task.wait(Sound.TimeLength)

TimeLength is a property of the sound to replace task.wait() as I wouldn’t want to be doing that every single time when I make a new “zone”

you can use sound.ended:Wait() in the local script or sound.ended:Connect(function())

1 Like

then I’ll also have to reference the 2 thousand sound files I have, and that’s just a bit too much

would ya’ll want me to send the LocalScript also? as the localscript is what plays the audio if the remote is fired.

It’s not bad, you can make your own function to make it easier. But regardless, your current script won’t get better, you need to restructure everything.

oh… Alright, I feel a bit lazy to restructure everything but I’ll try, and thanks

1 Like

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