Attributes (属性)

Image 1
Image 2
Image 3
Roblox Studio

监听 Attribute (属性) 更改事件

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)

设置 Attribute (属性)

local part = script.Parent

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

如果您觉得本教程对您有帮助,并且愿意支持我的工作,请考虑请我喝杯咖啡。

非常感谢您的支持!

请我喝咖啡