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

Sound playing not working on servers?

Asked by
P100D 590 Moderation Voter
8 years ago

So essentially I have this global radio function that will play music in a loop, with two seconds between each song. Each song is at least 120 seconds long. This works perfectly in Studio. However, when I publish this to a place, the print() call always outputs 0 and only plays the first second or two of the song in a loop. What am I doing wrong here?

music = game.ServerStorage.Music:GetChildren()

function randomize(tbl)
    math.randomseed(tick())
    local returntbl={}
    if tbl[1]~=nil then
        for i=1,#tbl do
            table.insert(returntbl,math.random(1,#returntbl+1),tbl[i])
        end
    end
    return returntbl
end

wait(2)

while true do
    local s = randomize(music)[1]:Clone()
    s.Name = "radiosong"
    s.Parent = script.Parent
    game.Workspace.newradiosong:Fire()
    s:Play()
    print(s.TimeLength)
    wait(s.TimeLength + 2)
end

Answer this question