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)
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.
This still happens. DidLoop and TimePosition in general seem extremely bugged and are difficult to work with in scripting.
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.
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)
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)