Sound does not play at all in a script, preview works fine

Title says all, no errors in output, any help would be greatly appreciated!

Screen Shot 2022-06-22 at 8.42.26 PM

	if Player.leaderstats["Stage"].Value < tonumber(part.Name) then
		script.Parent.VictorySound:Play()
		script.Parent.Sparkles1.Enabled = true -- Particles work fine, sound just doesn't play
		script.Parent.Sparkles2.Enabled = true
		script.Parent.Sparkles3.Enabled = true
		wait(1.5)
		script.Parent.Sparkles1.Enabled = false
		script.Parent.Sparkles2.Enabled = false
		script.Parent.Sparkles3.Enabled = false
	else
4 Likes

Have you tried to print out some things?( relevant)

  • do you have more relevant code?

Also, a tip: use task.wait instead of wait( affects performance and efficiency)

Also, I see you have there 3 scripts. Kind of bad practice - have you tried to use 1 main script instead?

4 Likes

Try adding this to your script:

script.Parent.VictorySound.Playing = true

So that full script shows:

if Player.leaderstats["Stage"].Value < tonumber(part.Name) then
        script.Parent.VictorySound.Playing = true
		script.Parent.VictorySound:Play()
		script.Parent.Sparkles1.Enabled = true -- Particles work fine, sound just doesn't play
		script.Parent.Sparkles2.Enabled = true
		script.Parent.Sparkles3.Enabled = true
		wait(1.5)
		script.Parent.Sparkles1.Enabled = false
		script.Parent.Sparkles2.Enabled = false
		script.Parent.Sparkles3.Enabled = false
	else
1 Like

What is the asset ID of the sound?

1 Like

Not sure why but this seemed to fix my issue, I’ll look into it and try to provide an explanation

1 Like

What makes the two different?


For some reason your sound:play is not loading the sound, but setting the sound.playing to true will load your sound.

I also think using sound.Loaded:Wait() will also accomplish this.

1 Like