Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I use CollectionService?

**Hello all. I want to create a Light System using CollectionService, but I'm unsure on how to do so.

https://devforum.roblox.com/t/tag-editor-plugin/101465

I'm using tageditor which I'm giving all my lights the "Light" tag. inside of the lights are PointLights.

I want to click a button and all lights with the Light tag to turn off, but I'm unsure on how to go. Any help is appreciated.**

1 answer

✓ Accepted answer

alright, first up CollectonService "tags" instances.. tagged instances can be accessed using CollectionService:GetTagged(name_of_tag).. you can then iterate through all of them and make them turn on..

CollectionService is commonly used to make Kill Bricks, but can be used to make whatever you want..

here is how you could accomplish what you want.

local CollectionService = game:GetService("CollectionService");
local lights = CollectionService:GetTagged("Light");

for _, light in pairs(lights) do
	light.Enabled = true
end

learn more about CollectionService here

2 comments

0

Thanks alot, didn't think It'd be that simple!

0

ya lol

This discussion is preserved as it was. New answers, comments, and votes are closed.