Draft preview · this lesson is still being technically validated. Browser experiments and reference material remain available; trusted completion is enabled after publication.
v2 · Activity 2 of 4 · attributes · configuration · 28 min Requires Roblox Studio
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.
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 |
|---|
local raw = part:GetAttribute("Range")
local range = type(raw) == "number" and math.max(0, raw) or 12The fallback handles missing or wrong-type configuration. The numeric branch validates the lower boundary.
New syntax: attributes, configuration
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, Brightness number attribute=2) Workspace/LampB (Part, no Brightness attribute) ServerScriptService/ConfigureLights (Script, RunContext=Server)
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"))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.
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.
This lab reads configuration once at attachment. Live configuration changes require a change signal and cleanup; do not imply this one-time read reacts automatically.
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.