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

My music sound won't play the soundId?

Hello, I have made this script which changes the soundId to a certain sound then plays it but for some reason it doens't play? This is a server script btw.

game.ReplicatedStorage.Functions.SoundChange.OnServerEvent:Connect(function(plr, id)
	local radio = game.Workspace.FE.Radio[plr.Name].Radio.Sound
	radio.SoundId = "rbxassetid://"..id
	repeat wait(1) until radio.SoundId ~= nil
	wait(1)
	radio:Play()
end)

4 comments

0

maybe the sound is deleted or something

0

Nah it's there because I can play it manually, just the script won't play it. Is there a different way to check if the sound has loaded maybe?

0

whats the hiearchy

0

your repeat loop is just going to break your script if you give the SoundId a nil value.

1 answer

The best way to play sound is to use the "Loaded" event before using the :Play() function. Here is an example of a simple sound playing script.

local audio = Instance.new('Sound', workspace)
audio.SoundId = 'rbxassetid://1838742547'
if not audio.IsLoaded then audio.Loaded:Wait() end
audio:Play()

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