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

Won't edit all the sounds help?

Asked by
NotSoNorm 777 Moderation Voter
9 years ago

I hear the sounds

except I can't change them :/

My loop won't edit the volume of all the children named " sound", how u do

local Audios = game.Workspace.DJBoardPRO:GetChildren()

script.Parent.MouseButton1Down:connect(function()
    for i,v in pairs(Audios) do
        if v.Name == "Sound" then -- creates a new thread, something like a ghost script
                v.Volume = v.Volume - .1
        end
    end
end)

0
Change line 5 to: if v:IsA("Sound") then This basically checks if the child is a sound, names don't matter legobuildermaster 220 — 9y

1 answer

Log in to vote
2
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

Your Problem

As you told me in the chat, the sounds are added dynamically. Due to this, you need to define 'Audios' inside the MouseButton1Down event! When you define the value then it becomes static, not dynamic. 'Audios' is not going to change from when you first defined it, and when you first defined it there was no children.

Code

script.Parent.MouseButton1Down:connect(function()
    local Audios = game.Workspace.DJBoardPRO:GetChildren()
    for i,v in pairs(Audios) do
        if v.Name == "Sound" then
            v.Volume = v.Volume - .1
        end
    end
end)
Ad

Answer this question