Make sound repeat

hi. so if i want to repeat between second 10 and 20 until a event gets fired and then jump to second 40. how would i do that?

3 Likes
local repeatSound = true
local audio = pathtoaudio

function repeatAudio(sound)
if not sound.IsLoaded then sound.Loaded:Wait() end

sound.TimePosition = 10
sound:Play()

repeat
if sound.TimePosition >= 20 then
   sound.TimePosition = 10
end
until not repeatSound
sound.TimePosition = 40
end

coroutine.wrap(repeatAudio)(audio)

event:Connect(function()
   repeatSound = false
end)
3 Likes

this wont work like intended since it doesnt check when it hits second 20

1 Like

i specified that i accidentally posted

1 Like

so this will give me back control over the sound after done?
also what exactly is a coroutine wrap? i like wraps with meatballs

2 Likes

why did you use (word)(word) since when that workks?

why did you use (word)(word) since when that workks?

  • repeatAudio is the function’s name and audio is the parameter (and yes it works)
coroutine.wrap(repeatAudio)(audio)

also what exactly is a coroutine wrap?

  • Coroutines make you able to run multiple lines of code in a script at once

YOUR SCRIPT doesnt work!!! please fix?!

Are there any errors in the output

from what I see, it should work?

Okay okay you are right :white_check_mark: :clap: :slightly_smiling_face:

1 Like

can i also put it in commas? like parameters in functions?

i dont know what you mean by that, do you want to play the function multiple times or play multiple sounds at the same time?

bro are you there???NOTHING OF ALL THAT ACTUALLY1 reply to my direct message!

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