workspace.DescendantAdded:Connect(function(desc)
if desc:IsA('Sound') then
if desc.Parent:IsA('BasePart') then
if (desc.Parent.Position - Root.CFrame.Position).Magnitude >= 30 then
desc.Volume = 0
local fx = script.Echo:Clone()
fx.Parent = desc.Parent
fx:Play()
fx.Ended:Connect(function()
fx:Destroy()
end)
end
end
end
end)
Well you are adding a child every time a child gets added. Essentially you made an infinite loop. Whenever you parent the clone it fires the event again. If you want an infinite loop you should use a while loop. If you don’t want an infinite loop then you should rework the logic of the system.
Also I’ve never really used these, but this might be worth looking into EchoSoundEffect since it seems to me to do what you’re trying to code.
workspace.DescendantAdded:Connect(function(desc)
if desc:IsA('Sound') then
if desc.Parent:IsA('BasePart') then
if (desc.Parent.Position - Root.CFrame.Position).Magnitude >= 30 then
desc.SoundId = script.Sound.SoundId
end
end
end
end)