SoundId not changing

I have a script where it changes a bunch of stuff. One of them is a soundId and for some reason it’s not changing at all

local SS = game:GetService("ServerStorage")
local BludBoss = SS.Maps:WaitForChild("BludBossFight")
local NormalMap = SS.Maps:WaitForChild("MainMap")
local SSS = game:GetService("ServerScriptService")
local MainTheme = game:GetService("Workspace").Music.MainSong
while true do
	wait(5)
	local Probability = math.random(1, 5)
	print(Probability)
	if Probability == 1 then
		MainTheme.SoundId = "rbxassetid://15705896057"
		MainTheme.TimePosition = 0
		SSS.MeteorShowerEvent.Disabled = true
		SSS.PortalEvent.Disabled = true
		SSS.MapRegen.Disabled = true
		local MSG = Instance.new("Message")
		MSG.Parent = game.Workspace
		MSG.Text = ("Regenerating map")
		wait(2)
		game.Workspace.Map:Remove()
		game.Workspace.Terrain.Walls:Remove()
		BludBoss.BludWalls:Clone().Parent = game.Workspace.Terrain
		wait()
		BludBoss.BLUD:Clone().Parent = game.Workspace.Terrain
		SSS.BludAttacks.Attacks.Enabled = true
		wait(2)
		MSG:Remove()
		wait(30) -- Done
		SSS.MeteorShowerEvent.Enabled = true
		SSS.PortalEvent.Enabled = true
		SSS.MapRegen.Enabled = true
		local MSG = Instance.new("Message")
		MSG.Parent = game.Workspace
		MSG.Text = ("You survived Blud")
		wait(2)
		game.Workspace.Terrain.BludWalls:Remove()
		game.Workspace.Terrain.BLUD:Remove()
		NormalMap.Map:Clone().Parent = game.Workspace
		NormalMap.Walls:Clone().Parent = game.Workspace.Terrain
		SSS.BludAttacks.Attacks.Disabled = true
		SSS.BludAttacks.Script.Active.Value = false
		MainTheme.SoundId = 'rbxassetid://16030156241'
		wait(2)
		MSG:Remove()
	end
end

Are there any errors in the output? If not, try stopping the song before changing the id.

1 Like

not a single error, and sure I’ll try that

I tried stopping the song before changing the id and nothing really changed

Are you playing the song to begin with?

yeah it’s playing. The script just changes the soundId of the song thats all

What method are you using to play the music?

the song just plays in loop all the time, when something happens it changes the id of the songs, I did this on other scripts I have no idea why it’s not working on this one tho

How is it playing the first place though? If it’s via the Playing property, try instead changing the sound id and then calling :Play()

idk why but it just seems like the id isnt changing through this script, I did try that but again doesnt work it’s weird

Does everything else in the if statement run?

yeah everything runs perfectly. The SoundId is the only thing giving me problems

Replace

MainTheme.SoundId = "rbxassetid://15705896057"
MainTheme.TimePosition = 0

with

MainTheme:Stop()
MainTheme.SoundId = "rbxassetid://15705896057"
MainTheme:Play()

nothing changed. This is super weird

Odd, not sure what the issue is. Keep me posted if you figure it out.

1 Like

Alright I will try to, thanks for trying to help

2 Likes

looked up the songs/sounds … 15705896057 has a length of 0:00. The other is 0:48.
Try to just focus on the songs/sounds nothing else, in a separate script. Just to see if you can get that working. A simple play script.

1 Like

I’ve went ahead and cleaned up the code a little bit, change it as you see fit. Note: You can separate things with a ; to clean up clutter.

Your sound ID is changing, the issue is that either the song you’re trying to use has been taken down (meaning; there’s nothing for the sound to play), or you aren’t playing the audio. I changed the audio ID of each audio, changed the Audios time position to 0, and played the audio. I also changed your while true do loop to a repeat function. It worked like a charm.

Fixed Script

local SS = game:GetService("ServerStorage");local BludBoss = SS.Maps:WaitForChild("BludBossFight");local NormalMap = SS.Maps:WaitForChild("MainMap")
local SSS = game:GetService("ServerScriptService");local MainTheme = game:GetService("Workspace").Music.MainSong
repeat
	wait(5)
	local Probability = math.random(1, 5)
	print(Probability)
	if Probability == 1 then
		MainTheme.SoundId = "rbxassetid://1837879082";MainTheme.TimePosition = 0;MainTheme.Volume = 1;MainTheme:Play()
		SSS.MeteorShowerEvent.Disabled = true
		SSS.PortalEvent.Disabled = true
		SSS.MapRegen.Disabled = true
		local MSG = Instance.new("Message")
		MSG.Parent = game.Workspace
		MSG.Text = ("Regenerating map")
		wait(2)
		game.Workspace.Map:Remove()
		game.Workspace.Terrain.Walls:Remove()
		BludBoss.BludWalls:Clone().Parent = game.Workspace.Terrain;BludBoss.BLUD:Clone().Parent = game.Workspace.Terrain
		SSS.BludAttacks.Attacks.Enabled = true
		wait(2)
		MSG:Remove()
		wait(30) -- Done
		SSS.MeteorShowerEvent.Enabled = true;SSS.PortalEvent.Enabled = true;SSS.MapRegen.Enabled = true
		local MSG = Instance.new("Message");MSG.Parent = game.Workspace;MSG.Text = ("You survived Blud")
		wait(2)
		game.Workspace.Terrain.BludWalls:Remove();game.Workspace.Terrain.BLUD:Remove()
		NormalMap.Map:Clone().Parent = game.Workspace;NormalMap.Walls:Clone().Parent = game.Workspace.Terrain
		SSS.BludAttacks.Attacks.Disabled = true;SSS.BludAttacks.Script.Active.Value = false
		MainTheme.SoundId = 'rbxassetid://1848354536';MainTheme.TimePosition = 0;MainTheme.Volume = 1;MainTheme:Play()
		wait(2)
		MSG:Remove()
	end
until script.Disabled

If this doesn’t fix the issue, then make sure you have everything in-between correct. If you’re missing one thing; the whole script will break.


1 Like

I found out that I had a script where if a value was false keep the id as the normal one, J2T script is very clean and easy to understand tho, deff will use it

1 Like

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