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

Sound script randomly stopped working?

Asked by 8 years ago

I have a sound script for ambient noises. It's designed to play an audio clip in a seamless loop by always playing a new audio before the current audio ends. It was working perfectly until today and I'm not sure why. Now, the sound doesn't even clone but the print() functions still fire.

This is the error I am receiving:

11:10:33.338 - attempt to call a number value

any ideas? thanks

--getSound
for i,v in pairs (script.Parent:GetChildren()) do
    if v:isA("Sound") then
        soundObj = v
        print("got sound ... " .. soundObj.Name)
    end
end

soundLength = soundObj.TimeLength
print("length = " .. soundLength)

function countDown(sound)
    sound:remove()
end

while true do
    local newSound = soundObj:clone()
    newSound.Parent = script.Parent
    newSound:play()
    print("played new sound .. " ..newSound.Name)
    delay(countDown(newSound), soundLength)
    print("delay fired")
    wait(soundLength-1)
end

1 answer

Log in to vote
0
Answered by 8 years ago
 Make sure that both the script, and the sound, is located in workspace. It will not work if it is placed anywhere but workspace, you may have it located in ServerScriptService, if so, move them to Workspace.

 If that does not work, than it is a problem with the script itself, and that is most likely to be the case. I'm not the greatest with scripting much at all, though, give it a shot. I have written music/sound scripts before, and most of the time, that usually seem to be the case.

 Also, make sure you own the sound, it is possible the owner of the sound put it off sale all of a sudden, so nobody else but the owner, or anybody who bought the sound, works. I have had that happen to me as well before.
Ad

Answer this question