so, i have a timer that whenever the time goes down, it makes a sound, but sometimes the sound doesnt really play correctly, i made a video so yall can see what i mean:
i did all the things u said in that post, but im still getting the same result shown in the video
this is how the script looks after i did the changes:
local ContentProvider = game:GetService("ContentProvider")
ContentProvider:PreloadAsync({sound})
while task.wait(.5) do
if not sound.IsLoaded then
sound.Loaded:Wait()
end
sound:Play()
end
again, the code is in a local script, so i dont know if that has something to do with it
Why are you doing all this waiting and sound loading within the loop?
The sound should be loaded into the workspace when the game is loaded, way before your timer is even activated.
In your timer script reference the workspace.sound at the beginning with a WaitForChild, then just play it when the timer runs out.
while task.wait(.5) do
sound:Play()
end
will just keep starting the sound every half second.
if timer == 0 then
sound:Play()
end
will work when the timer hits 0, and only play the sound 1 time.
I didnt say i wanted the sound to play when the timer hits 0, i want the sound to play when the times changes. The code i provided is just a test, but it is basically how my main script works, it plays when the timer changes
also all the loading stuff is just based on the replies that i’ve got in this post
A part, but I’ve tried it in an attachment and workspace as well. I’ve created a repro example to demonstrate this is a problem.
The following bug repro server script works without much setup needed. To test, run any experience and insert anything into the workspace camera and observe the sound behavior
local function twinklemaker()
local starsound = Instance.new("Sound")
starsound.SoundId = "rbxassetid://9060788686"
starsound.RollOffMaxDistance = 2048
starsound.RollOffMinDistance = 10
starsound.RollOffMode = Enum.RollOffMode.Linear
starsound.Volume = 0.04
return starsound
end
local function bugtest()
local part = Instance.new("Part")
part:PivotTo(workspace.Camera.CFrame)
part.Anchored = true
part.Parent = workspace.Camera
workspace.Camera.ChildAdded:Connect(function()
local folder = Instance.new("Folder")
folder.Name = "*"
folder.Parent = workspace
local testsound = twinklemaker()
--testsound.SoundId = "rbxassetid://9060788686"
testsound.Parent = workspace.Camera.Part
local first = coroutine.create(function()
testsound:Play()
end)
coroutine.resume(first) -- comment out this line and you'll experience no problems!
local sounds = {}
local testcount = 7
while testcount > 1 do
task.wait(1)
testcount -= 1
local clone = testsound:Clone()
clone.Name = "sound"..testcount
clone.Volume = testcount/14
print(script.Name)
table.insert(sounds, clone)
clone.Parent = part
clone:Play()
end
end)
end
bugtest()
See my comment tacked onto the “coroutine.resume” line. Basically when that line of code is removed, the sounds play every time. But with that line, the sound doesn’t audibly “play” the first 2 or so times. Even if the sound is preloaded or it’s Playing property is true, it doesn’t matter
Nope. I think a bug report should be posted about this. I’m just surprised that there hasn’t been much talk surrounding this problem on the Forum, because I’ve encountered this bug across multiple scenarios