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

Works on studio but not in-game, what's the problem?

Asked by
uZelt 15
9 years ago

The script is in a folder called "AudioController" and the music IDs are in another folder called "Songs"

local sound = Instance.new("Sound")
sound.Parent = game.Soundscape
sound.Name = "CoolAudio"

local number = 1
local songs = script.Parent.Songs:GetChildren()

local currentsong = 1
local nowplaying = 0

for i=1,#songs do
    songs[i].Name = tostring(number)
    number = number + 1
end

function cycle()
    local song = script.Parent.Songs:FindFirstChild(tostring(currentsong))
    if song == nil then
        currentsong = 1
        wait()
        cycle()
    else
        nowplaying = song.Value
        sound.SoundId = "rbxassetid://" .. tostring(song.Value)
        sound:Play()
        wait(sound.TimeLength)
        currentsong = currentsong + 1
        sound:Stop()
        cycle()
    end
end

cycle()

1 answer

Log in to vote
2
Answered by 9 years ago

In order for your song to be heard ingame, it has to be in the Workspace, Soundscape is like a storage place, not a song-playing service.

0
The audio now plays in-game though it stops as soon as you actually spawn. uZelt 15 — 9y
0
Try and redo the script, this time make the sound play and exist in the workspace, and make is more simple, there are more less complicated and efficient ways to play sound like this. laughablehaha 494 — 9y
Ad

Answer this question