For loop not injecting sound

Hi, I’m fairly new to for loops but I’ve seen no topics on this problem so here is my problem; I don’t want to keep putting a sound in every single dummy so I use a for loop to put it in the dummies, except it only puts it in one dummy, not all of the dummies, and I don’t know why. Can someone help? Here is my current code:

local sound = workspace.SpawnerDummy.Scream

for _,v in pairs(workspace.Dummys:GetChildren()) do
	if v.Name == "Dummy" then
		sound:Clone()
		sound.Parent = v
	end
end

nevermind, no help is needed I solved it

Try using an offset for your loop. This somehow fixed my issue when I had this.

Disregard, sent this right as you said you didn’t need help, lol

local sound = workspace.SpawnerDummy.Scream;
local offset = 0
for i = 1, #workspace.Dummys:GetChildren() do
local dummy = workspace.Dummys:GetChildren[i - offset]
if dummy.Name == "Dummy" then 
sound:Clone().Parent = dummy
offset += 1    
continue
end
offset += 1
end

Turn sound:Clone() into local sound = sound:Clone().

lol sorry! I realized i was just cloning the sound but not making the cloned sound a variable, so thats where it went wrong. thanks for helping though!

1 Like

Just realized that was the only problem… I overcomplicated it for no reason lol