Draft preview · this lesson is still being technically validated. Browser experiments and reference material remain available; trusted completion is enabled after publication.
v2 · Activity 3 of 4 · collectionservice · tags · 28 min Requires Roblox Studio
CollectionService groups Instances by a tag. GetTagged returns current members; added and removed signals describe membership changes.
Connect signals and initialize the current bank. Keep an attachment table keyed by Instance so overlapping discovery does not set up the same object twice.
Color current and newly tagged WorkshopLamp BaseParts orange. Log each object only once and release the attachment record when its tag is removed.
Interface: Complete the documented Studio hierarchy and self-check the behavior outside the browser.
| Input | Expected |
|---|
for _, object in ipairs(CollectionService:GetTagged("WorkshopProp")) do
if object:IsA("BasePart") then print(object.Name) end
endThe tag discovers membership; the class check validates which members support Part behavior.
New syntax: collectionservice, tags
Your explanation is a self-check. Exact wording is not automatically graded.
Self-checked Studio exercise. A saved checklist records your own review; no uploaded place file or screenshot is executed here.
Workspace/LampA (Part, tag WorkshopLamp) Workspace/LampB (Part) ServerScriptService/TaggedLamps (Script, RunContext=Server)
Main guided reference implementation; use the hierarchy’s stated Script or ModuleScript type.
local CollectionService = game:GetService("CollectionService")
local attached = {}
local function attach(part)
if attached[part] or not part:IsA("BasePart") then return end
attached[part] = true
part.Color = Color3.fromRGB(234,120,40)
print("Attached", part.Name)
end
CollectionService:GetInstanceAddedSignal("WorkshopLamp"):Connect(attach)
CollectionService:GetInstanceRemovedSignal("WorkshopLamp"):Connect(function(part) attached[part] = nil end)
for _, part in ipairs(CollectionService:GetTagged("WorkshopLamp")) do attach(part) endClient-side tag changes do not establish server membership; inspect the server view.
Check exact tag capitalization.
This is a bounded learning lab. It has not been executed in an approved Roblox Studio environment by this website.
A checked checklist records your own review, not automated project competence or a community verification.
CollectionService groups Instances by a tag. GetTagged returns current members; added and removed signals describe membership changes.
Connect signals and initialize the current bank. Keep an attachment table keyed by Instance so overlapping discovery does not set up the same object twice.
A tag does not promise a class. Check IsA before using BasePart properties. Tag the Part itself in this lesson, not a surrounding Folder.
Replace this code with the starter? Download your draft to keep a copy.
Edit and run these files in Roblox Studio. This browser has no Roblox services, physics, or replication.
Your output will appear here.
Sign in with RoCreators to save private progress across devices. Community verification is separate.