My script is supposed to put the volume of the specified sounds to 0, however, it doesn’t and it does not return any errors in the console.
Code here:
script.Parent.Humanoid.Died:Connect(function()
local Descen = script.Parent:GetDescendants()
for i, child in ipairs(Descen) do
if child.Name == {script.Parent.Head:WaitForChild("ScreamSounds"):GetChildren().Name} and child.Name == {script.Parent.OuchieSounds:WaitForChild("Sounds"):GetChildren().Name} then
child.Volume = 0
end
end
end)
You currently attempting to compare a string value to a table value. You need to iterate over the table value instead and for each of its items compare it with the desired value, in this case child.Name.
script.Parent.Humanoid.Died:Connect(function()
local Descen = script.Parent:GetDescendants()
for i, child in ipairs(Descen) do
for x,child2 in ipairs(script.Parent.Head:WaitForChild("ScreamSounds"):GetChildren()) do
for y, child3 in ipairs(script.Parent.OuchieSounds:WaitForChild("Sounds"):GetChildren()) do
if child.Name == child2.Name and child.Name == child3.Name then
child.Volume = 0
end
end
end
end
end)