How can you get every instance of something in roblox?

How can you get every single instance of an object in roblox, Basically, What I mean is a script gets every single sound in the game. I would believe I would have to use collection Service But i’m not sure, And im also not familiar with the collection service environment, All I know is that it exists.

1 Like
local sounds = {}

for _, v in game:GetDescendants()) do
   if v:IsA("Sound") then
      table.insert(sounds, v)
   end
end
1 Like

Okay, Now we have the objects, How could I change a property like sound?

Use descendant

for _, Child in pairs(game:GetDescendants())do
	if Child:IsA("Sound")then
		--code
	end
end

Use Collection Service, here is how to add tags: Add and Remove Tags from the Properties Panel [Beta]

local CS = game:GetService("CollectionService")
local Sounds = CS:GetTagged("Sound")

for _, Child in pairs(Sounds)do
	--code
end
2 Likes

Thank you so much! I remember you earlier on the forums, Thanks for helping me now and earlier :slight_smile:

1 Like

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