local Stop = script.Parent
local sounds = script.Parent.Parent.Parent.ScrollingFrame:GetChildren().sound
function onClick(Stop)
sounds:stop()
end
Stop.MouseButton1Click:connect(onClick)
✓ ANSWER ACCEPTED
How do you select all Childs with one variable?
1 answer
✓ Accepted answer
Helo Xianon,
Great question!
You are off to the right start, so great job.
local Stop = script.Parent
local sounds = script.Parent.Parent.Parent.ScrollingFrame:GetChildren().sound
function onClick(Stop)
sounds:stop()
end
Stop.MouseButton1Click:connect(onClick)
The first error we can see is the ".sound" on the end of your variable.
Secondly, a 'for' statement would be needed in order to go through
function onClick()
for i,v in pairs(script.Parent.Parent.Parent.ScrollingFrame:GetChildren()) do -- Get all the Children in script.Parent.Parent.Parent.ScrollingFrame
if v:IsA("Sound") then --Check if 'v' is a sound
v:Stop() -- Stop it
end
end
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Thanks, Creative Energy.
No. This is incorrect. You need to iterate through the table 'sounds', then check if each object is a sound, and then call the 'stop' method on the object. You cannot call IsA or Stop on a table.
So it is. Making the corrections.