Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My music sound won't play the soundId?

Asked by 5 years ago

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)
0
maybe the sound is deleted or something RetroGalacticGamer 331 — 5y
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? CrazyCorrs 98 — 5y
0
whats the hiearchy jakebball2014 84 — 5y
0
your repeat loop is just going to break your script if you give the SoundId a nil value. Gey4Jesus69 2705 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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()
Ad

Answer this question