I am pretty new to using CollectionService, I already got a tag for the parts, I just wanna know, how would I be able to destroy those parts with the tag? I can't figure it out. Any help is appreciated
✓ ANSWER ACCEPTED
How can I destroy parts that have a tag (CollectionService)?
1 answer
✓ Accepted answer
The CollectionService:GetTagged() function allows you to retrieve all the instances with a certain tag. It returns a table, through which you can iterate through (usually by a for loop) and do what you want to each instance.
For example:
local CollectionService = game:GetService("CollectionService")
local tagged = CollectionService:GetTagged("tag")
for index, value in pairs(tagged) do
print(value.Name)
end
Or in your case, you replace line five with value:Destroy().
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
Read the documentation for CollectionService at: https://developer.roblox.com/en-us/api-reference/function/CollectionService/
is it possible for me to add it in a while loop? also everytime i try to add wait(seconds) to it, it wont work
You'll have to further describe your use case. Although you can, I don't see why as it would be very round-about; also for loops are very different from while loops and wait() cannot come in the declaring line, only inside the scope.
For more information on loops, read here: https://developer.roblox.com/en-us/articles/Loops