DidLoop sometimes fires twice (in a Sound object)

Title is self explanatory. This happens at random and seems to simultaneously fire at the end and beginning of a sound (seen in the video, loops 3-4, 5-6, 8-9, so on.). It happens with other soundIDs as well. any reason why this is happening?

Here’s the code:

wait(4)

script.Parent:Play()

print("loop started.")

script.Parent.DidLoop:Connect(function(soundId,loopNumber)
print("loop number:",loopNumber,"| time position:",script.Parent.TimePosition)
end)
1 Like

In this case I believe using DidLoop in sound is a bugged feature but I am not sure

1 Like

Apparently this still appears to be a thing a couple of years later. I’ve even had it fire 3 times in a row on rarer occasions. Using the code sample on the Sound documentation in a blank template place can easily replicate this.

2 Likes

This still happens. DidLoop and TimePosition in general seem extremely bugged and are difficult to work with in scripting.

image
Above output happened within a second. The DidLoop warns are tied to the sound I’m using’s .DidLoop event, and the sound is approximately 48 seconds long. It only looped once, but the event triggered twice anyways.

2 Likes

If it’s really a bug try making a custom DidLoop “signal” by checking if previous time position is higher than current (meaning last time pos was the end of the sound and current is the start)

1 Like

Hey there! Sorry to have missed this. Saw @Polyhex 's tweet.

I’ve filed a bug and investigating and will get back to everyone here.

4 Likes

Hey @Polyhex @ChiDj123 @ShadokuSan @Jblocks12321 @WhoCouldThisPersonBe

@ReallyLongArms found and fixed it. Expect it to fully roll out to all users the week of Valentine’s day.

8 Likes

I’m building a game for both modern and four-year-old versions of Rōblox.

Does adding a debounce help?

local debounce = true
sound.DidLoop:Connect(function()
  if debounce then return end
  debounce = true

  -- INSERT LOGIC HERE

  delay(1, function() debounce = false end) 
end)

Hi - we rolled out a change that should hopefully fix this. Is it still happening on your end?

Hi, I am still experiencing this issue.