Sounds not playing?

Hallo, I’ll try to summarize this as best I can.

When you load a sound into a player’s torso, for example (it can be any item in workspace), with the sound having its PlayOnRemove setting set to True, and then delete it (either by pressing Delete or by removing it via script), it doesn’t play. If you do the same from the player’s PlayerGui, however, it plays half the sound before stopping. Am I doing something wrong?

2 Likes

findFirstChild and clone are deprecated. Do not use them for new work.

As for the actual issue, can confirm, it does exactly as described above.

3 Likes

You startled me with the deprecation comment, but I’m glad it’s not an issue that’s unique to me. I can’t work on my sound system without them working properly.

1 Like

@spotco

I’m having the same issue since last client update. This also includes playing sounds in any instances within the character, even if it was created from a seperate source. PlayOnRemove doesn’t matter.

This has literally broke sounds on at least 1/2 of my games including my sound engine, pls revert/fix?

1 Like

Haven’t made any changes related to this recently but I’ll take a look.

@ChadTheCreator
I’m trying it with code like this (Inside StarterCharacterScripts).

local test = Instance.new(“Sound”)
test.SoundId = “rbxassetid://487726169”
test.Parent = script.Parent.Torso
test.PlayOnRemove = true
print(test.IsLoaded)
test.Parent = nil

This does not work, the print is false and there is an error message in the console (onSoundLoaded cannot find SoundService…). Is this the problem you’re getting?

This is fixed by waiting until IsLoaded is true for the sound you’ve just created/cloned.

@BuildIntoGames
I’m trying this code (Inside StarterCharacterScripts):

local test = Instance.new(“Sound”)
test.SoundId = “rbxassetid://487726169”
test.Parent = script.Parent.Torso
test.Looped = true
test:Play()

And the sound plays. Can you give more specifics on what’s not working?

That sounds familiar. So I should just add a line that says something like…

while sound.IsLoaded == false do wait() end

…this?

Nothing should ever require you to do that. There has to be a better way. If there isn’t then something is wrong.

1 Like

@ChadTheCreator
Yes, I think that should work.

@1waffle1
PlayOnRemove won’t work unless the sound is loaded. How is this problematic?

1 Like

I’m saying you shouldn’t need a loop with a wait in it in order to tell when something happens. It’s a hacky alternative to events. Something like sound.Loaded:wait() sound:Destroy() would be nicer.

2 Likes

slightly better:

while sound.IsLoaded == false do sound.Changed:wait() end

1 Like

does it fire Changed? I thought only scripted changes fired Changed.

Hmm, now I’m not sure anymore.

EDIT: yeah it does work, TimeLength is set when the sound is being loaded and that triggers the Changed event.

Try if you want:

local sound = Instance.new("Sound", workspace)
sound.SoundId = "rbxassetid://487726169"
sound.PlayOnRemove = true
while not sound.IsLoaded do sound.Changed:wait() end
sound:Destroy()

Won’t work without fourth line and it’ll work fine for both the wait() and .Changed:wait() versions.

1 Like

For example, my animation engine makes parts within other parts in the character. When a sound is placed in one of these parts, preloaded, and played, it doesn’t work anymore. No errors, running in localscript. I’ll try to get a repo later when I get to a computer.

I’ve tried waiting until the sound is loaded, nothing seems to work. The sound won’t play in a test server, regardless of whether or not I’m using the PlayOnRemove way or the simple :Play() way.

For reference, this is what prints when I delete the sound (after waiting for it to load, with PlayOnRemove set to true):
onSoundLoaded cannot find SoundService Sound(Fire3) SoundId(rbxassetid://166423137)

Update: Solved it. Apparently my sounds MinDistance was set to 0, which causes it to never play

1 Like

Still an ongoing issue. Any news on this?

Edit:
I have a repo. If you make a new sound in ANY part in workspace, it refuses to play. By placing it in a global area like Workspace by itself, it runs fine. MaxDistance/MinDistance are not making a difference.

I know this hasn’t been replied to for almost 4 years ago at the time of posting, but I genuently had this problem myself and could not find anywhere else where someone else had this specific problem and, therefore, had to figure it out myself. I’d now like to share this information with future developers having this exact problem and coming to this topic to seek answers.

The solution is to set EmitterSize to a positive integer. Simple, but hard to find at first glance.

1 Like