For _, v loop not running

You can write your topic however you want, but you need to answer these questions:
I’m trying to write a function that when said function is called to “remove” all audio from ReplicatedStorage, it does exactly that. But when I try to run it, it doesn’t run. I’ve tried debugging, restarting Studio, Changing where the function gets called from, but it still doesn’t work

Function:

function Cleanup()
	task.wait(1)
		print("start")
		for _, v in pairs(game.ReplicatedStorage.TrafficCams.CameraSnapshot:GetDescendants()) do
		if v:IsA("Audio") then
			print("✔️")
			v.Playing = false
			v.Volume = 0
		end
	end
end

Any help would be appreciated. Thanks in advance!

Maybe I’m absolutely wrong here, but I never heard of an “Audio” instance. Are you referring to a “Sound” Instance? You would need to use :IsA(“Sound”) in that case.

1 Like

Try this:

function Cleanup()
	    task.wait(1)
		print("start")
		for _, v in pairs(game.ReplicatedStorage.TrafficCams.CameraSnapshot:GetDescendants()) do
		  if v:IsA("Audio") then
			print("✔️")
			v.Playing = false
			v.Volume = 0
		  end
        end
end

Yes… I meant to put sound. That’s what happens when you code while sleep deprived lol.

my guy there is no audio its sound and also you didnt run the function

function Cleanup()
	task.wait(1)
	print("start")
	for _, v in pairs(game.ReplicatedStorage.TrafficCams.CameraSnapshot:GetDescendants()) do
		if v:IsA("Sound") then
			print("✔️")
			v.Playing = false
			v.Volume = 0
		end
	end
end

Cleanup()

In my defense, I could’ve sworn it was Audio at some point in time

yeah happens to me often , i once forgot that remote fuctions from a client give the player to the server and i spent 2 hours wondering why it wasnt working lol

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.