Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Sound.SoundID not changing the text?

I am currently making a script that selects random music to play, once played, the text on in the GUI Changes to the name of the song. The soundID matches Sound that is inserted in the instance but it still does not work.For some reason, it isn't changing the text. The song will play but the text just wont change. There is no error in the output. I have changed where the Sound is inserted (Workspace, for example) But doesnt seem to fix the problem. I have also tried changing The textlabel to a Varible of "Title" so I could do Title.Text but that isnt working either.

Sound = Instance.new("Sound",game.StarterGui.Music.TextLabelMe.Script)




local Music = {438917260}
	
while true do
	Current = Music[math.random(1,#Music)]
	wait(4)
	Sound.SoundId = "http://www.roblox.com/asset?id="..Current
	Sound.Volume = 1
	Sound:Play()
	wait(115)
	Sound:Stop()
	end

	if script.Sound.SoundId == "http://www.roblox.com/asset?id=438917260" then
	script.Parent.Text = "Twenty One Pilots - Heathens"
	end
	

1 answer

✓ Accepted answer

You need to move the "if-statement" inside the loop.

Example:

Sound = Instance.new("Sound",game.StarterGui.Music.TextLabelMe.Script)

local Music = {438917260}

while true do
    Current = Music[math.random(1,#Music)]
    wait(4)
    Sound.SoundId = "http://www.roblox.com/asset?id="..Current
    Sound.Volume = 1
    Sound:Play()
    if script.Sound.SoundId == "http://www.roblox.com/asset?id=438917260" then
    script.Parent.Text = "Twenty One Pilots - Heathens"
    end
    wait(115)
    Sound:Stop()
    end

This discussion is preserved as it was. New answers, comments, and votes are closed.