Draft preview · this lesson is still being technically validated. Browser experiments and reference material remain available; trusted completion is enabled after publication.
Configure props with attributes
v2 · Activity 1 of 0 · attributes · configuration · 28 min Requires Roblox Studio
Chapter outline
Attributes are named values attached to Instances. GetAttribute returns the authored value or nil. Use Properties to add a numeric Brightness attribute to each lamp.
Configuration is still data. Check its type and range before assigning it to a light property. A missing value gets a documented default; a negative value is not useful brightness.
Your task
For each LampA and LampB, create a PointLight child if needed. Read Brightness, use 1 if missing/wrong-type, and clamp valid numbers to 0..5. Set Range 12.
Interface: Complete the documented Studio hierarchy and self-check the behavior outside the browser.
| Input | Expected |
|---|
Syntax in this activity
New syntax: attributes, configuration
Earlier ideas used here
- modules
- require
Self-check rubric
- Missing configuration uses the documented default.
- Set Brightness to 9; next Play clamps it to 5.
- Set a text attribute value; next Play uses 1.
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, Brightness number attribute=2) Workspace/LampB (Part, no Brightness attribute) ServerScriptService/ConfigureLights (Script, RunContext=Server)
- Build two anchored lamp Parts.
- Add a numeric Brightness attribute of 2 to LampA in Properties. Leave LampB absent.
ServerScriptService/ConfigureLights.server.luau
Main guided reference implementation; use the hierarchy’s stated Script or ModuleScript type.
local Workspace = game:GetService("Workspace")
local function configure(part)
local raw = part:GetAttribute("Brightness")
local brightness = 1
if type(raw) == "number" and raw == raw and math.abs(raw) < math.huge then brightness = math.min(5, math.max(0, raw)) end
local light = part:FindFirstChildOfClass("PointLight") or Instance.new("PointLight")
light.Brightness = brightness
light.Range = 12
light.Parent = part
print(part.Name, brightness)
end
configure(Workspace:WaitForChild("LampA"))
configure(Workspace:WaitForChild("LampB"))Expected output
- LampA PointLight brightness is 2; LampB brightness is 1.
- Each light has Range 12.
Studio assessment checklist
Multiplayer tests
- Run a local server and at least one client; compare server and client context where the activity uses both.
Troubleshooting and production considerations
An attribute and a property are different namespaces. GetAttribute reads the custom attribute.
The fallback must happen before assigning a nil or incompatible type to PointLight.Brightness.
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.
For each LampA and LampB, create a PointLight child if needed. Read Brightness, use 1 if missing/wrong-type, and clamp valid numbers to 0..5. Set Range 12.
Reset starter
Replace this code with the starter? Download your draft to keep a copy.
Code
Studio source fileEdit 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.