Music Speaker System - Issue with creating one Sound Object for multiple locations each of the same property

As I begin my extremely long journey into programming, I’ve been making attempts to create a music system which inserts one Sound Object into multiple speakers of the same properties located inside the same folder in order to make it seem like the sound is coming out of the speakers to create realism.

I’ve been facing a few issues to do with the correct method of getting the script to locate a folder in the workspace > finding all the models inside that folder > inserting a sound object into a specifically named part called AudioPart in each of the models. I’m not sure whether I should simply just use :GetChildren then something I don’t know or actually have to somehow use a method to create several Sound Objects to go into each AudioPart.

Green highlights where we want to insert one Sound Object into each but multiple Audio Parts

image

Audio Part is where the Sound Object will be created & inserted.

I guess you can call this a big noober-move from me since I’ve tried using :GetChildren but of course it only inserts one Sound Object into one AudioPart.

local HttpService = game:GetService("HttpService")

local Sound = Instance.new("Sound") 
--local Eq = Instance.new("EqualizerSoundEffect")
Sound.Name = "Music"
Sound.Volume = 0.11 --0.4
Sound.Parent = workspace.FRIZZEDSPEAKERS:GetChildren()

Remember, I’m trying to get one Sound Object to be created inside multiple of the AudioParts, I’m just not sure if I’m using :GetChildren correctly or if I should be using something else in order to create multiple Sound Objects but one for each AudioPart.

Thank you for your time & support, I look forward to reading back on how I could somehow tackle this problem. :v:

So, you seem very adamant that it has to be one Sound Object with multiple parents. At the moment, Roblox does not support this.

Now, to do what you desire with that aside, you have to do the following:

-- The following assumes you want the parent to be each "AudioPart":
-- (I advise you to name game objects in PascalCase)
local frizzedSpeakers = workspace.FRIZZEDSPEAKERS;

local templateSound = Instance.new("Sound");
-- Set all of the values you need to do here.

for _, frizzedSpeakerModel in pairs(frizzedSpeakers:GetChildren()) do
    local sound = frizzedSpeakers:Clone();
    sound.Parent = frizzedSpeakerModel.AudioPart;
end

In essence, we create one template, clone it so every cloned value is the same (in the moment, at least), and attach each clone to be a child to each “AudioPart” instance.

1 Like