Random sound is not being played even after I followed a supposed solution on the DevForum

My problem is that my script, even when the script is activated, even when there are no errors, will not play any sound (volume on sound instances, local volume, and studio volume are all 100%)

I used the solution from this topic to fix my issue but it did not work. I am facing the same issue, no sound is playing. There is the code below:

while wait(1) do
	local item = workspace.Rumbling:GetChildren()
	local randomitem = item[math.random(1, #item)]
	randomitem:Play()
end

I would upload a video but it just won’t work, sorry.

P.S: I know it’s gonna be some silly oversight (like most of my issues) but I seriously have no idea what I’m doing wrong.

Is there only sounds in the folder from workspace, and is the MinRolloff set to 0? and maxrolloff set to higher

(Off topic) you could try upload a video in a different website (probably youtube) then put the link here

1 Like

The sounds are in a folder in workspace called “Rumbling”
The sounds have RollOffMaxDistance of 10,000
The sounds have RollOffMinDistance of 10

What needs to be changed for this to work?

Hey, since you’re playing a sound every second, if there’s just a few sounds inside the folder, it might be that the script is continuously calling :Play() on a sound that hasn’t actually started playing.

For example if your sounds last 30 seconds and gets progressively louder, the volume of the sound at the first ~3 seconds might just be too low to be noticeable.

If you send me a demo place file with the sounds, I could try looking into it for you!

This is most likely the case, also @sharker12312 are you sure the sounds are owned by you and not private?

1 Like

I got these sounds from the library, they seem to be working fine in the preview. Would changing the wait time to the sounds TimeLength fix the issue?

TimeLength is also part of the sound loading functionality.

Try this instead,

while wait(1) do
	local item = workspace.Rumbling:GetChildren()
	local randomitem = item[math.random(1, #item)]
        if not randomitem.IsLoaded then
           randomitem.Loaded:Wait()
        end
	randomitem:Play()
end

Also, is this code on the client or server?

The code I have mentioned in the post is server sided code, the code doesn’t seem to be working. Same issue, no errors are present either, some of the logic is still broken. Would you like a demo place file to see what issue I’m having?
By the way, it is not a computer glitch. The footsteps, death, and jumping sounds all work fine.

try this code

	local item = workspace.Rumbling:GetChildren()
	local randomitem = item[math.random(1, #item)]
local cln = randomitem:Clone()
cln.Parent = workspace
cln:Play()
game.Debris:AddItem(cln,cln.TimeLength)
end

Yeah, a demo place file would be great as well.

Where is the script parented at?

Oh my goodness, what a silly problem!
I had put this loop, AFTER, I made a “while true do” loop.
I figured this out trying to make a demo place, I realised my mistake then and there.
Thanks for helping me out @oSudden @Callum_Cloth @T3_MasterGamer and @Actulurus. I’ll select the solution now.
By the way, @oSudden and @Callum_Cloth’s code worked with equal success.

4 Likes

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