Draft preview · this lesson is still being technically validated. Browser experiments and reference material remain available; trusted completion is enabled after publication.

← Back to journey

Apply one behavior to tagged props

v2 · Activity 1 of 0 · collectionservice · tags · 28 min Requires Roblox Studio

Chapter outline
Loading draft…
Mini-mission

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.

Your task

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.

InputExpected
Syntax in this activity

New syntax: collectionservice, tags

Earlier ideas used here
  • attributes
  • configuration
Self-check rubric
  • Existing and added membership both work.
  • A tagged Folder is ignored safely.
  • Remove and re-add a Part tag; one fresh attachment log occurs.

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.

Build this hierarchy

Workspace/LampA (Part, tag WorkshopLamp)
Workspace/LampB (Part)
ServerScriptService/TaggedLamps (Script, RunContext=Server)
  1. Add WorkshopLamp to LampA using the Tags section.
  2. Leave LampB initially untagged; add its tag from the server during Play for the dynamic check.
ServerScriptService/TaggedLamps.server.luau

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) end

Expected output

  • LampA is colored and logged during setup.
  • LampB is colored and logged when tagged later.

Studio assessment checklist

Multiplayer tests

  1. Run a local server and at least one client; compare server and client context where the activity uses both.
Troubleshooting and production considerations

Client-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.

Your goal

Color current and newly tagged WorkshopLamp BaseParts orange. Log each object only once and release the attachment record when its tag is removed.

Reset starter

Replace this code with the starter? Download your draft to keep a copy.

Code

Studio source file
Luau keyword highlighting · Ctrl/⌘ + Enter: Run · Esc: leave editor

Edit and run these files in Roblox Studio. This browser has no Roblox services, physics, or replication.

Your output will appear here.

Ready