Attributes

Image 1
Image 2
Image 3
Roblox Studio

Listening Attribute Change Event

local part = script.Parent

local function updateColor()
    local status = part:GetAttribute("Status")
    if status == "Active" then
        part.Color = Color3.fromRGB(0, 255, 0)  -- Green
    elseif status == "Inactive" then
        part.Color = Color3.fromRGB(255, 0, 0)  -- Red
    elseif status == "Maintenance" then
        part.Color = Color3.fromRGB(0, 0, 255)  -- Blue
    else
        part.Color = Color3.fromRGB(255, 255, 255)  -- White
    end
end

updateColor()

part:GetAttributeChangedSignal("Status"):Connect(updateColor)

Setting an Attribute

local part = script.Parent

part:SetAttribute("Status", "Active")
Image 1
Roblox Studio

If you found this tutorial helpful and would like to support my work, please consider buying me a coffee.

Thank you very much for your support!

Buy me a coffee