Skip to main content

AttributeValue

Allows access to an attribute like a ValueObject.

local attributeValue = AttributeValue.new(workspace, "Version", "1.0.0")
print(attributeValue.Value) --> 1.0.0
print(workspace:GetAttribute("version")) --> 1.0.0

attributeValue.Changed:Connect(function()
	print(attributeValue.Value)
end)

workspace:SetAttribute("1.1.0") --> 1.1.0
attributeValue.Value = "1.2.0" --> 1.2.0

Properties

Value

AttributeValue.Value: T

The current property of the Attribute. Can be assigned to to write the attribute.

Changed

This item is read only and cannot be modified. Read Only
AttributeValue.Changed: Signal<()>

Signal that fires when the attribute changes

Functions

new

AttributeValue.new(
objectInstance,
attributeNamestring,
defaultValueT?
) → AttributeValue<T>

Constructs a new AttributeValue. If a defaultValue that is not nil is defined, then this value will be set on the Roblox object.

ObserveBrio

AttributeValue:ObserveBrio(conditionfunction | nil) → Observable<Brio<any>>

Handles observing the value conditionalli

Observe

AttributeValue:Observe() → Observable<any>

Observes an attribute on an instance.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Constructs a new AttributeValue. If a defaultValue that is not nil\nis defined, then this value will be set on the Roblox object.",
            "params": [
                {
                    "name": "object",
                    "desc": "",
                    "lua_type": "Instance"
                },
                {
                    "name": "attributeName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "defaultValue",
                    "desc": "",
                    "lua_type": "T?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "AttributeValue<T>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 37,
                "path": "src/attributeutils/src/Shared/AttributeValue.lua"
            }
        },
        {
            "name": "ObserveBrio",
            "desc": "Handles observing the value conditionalli",
            "params": [
                {
                    "name": "condition",
                    "desc": "",
                    "lua_type": "function | nil"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<Brio<any>>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 60,
                "path": "src/attributeutils/src/Shared/AttributeValue.lua"
            }
        },
        {
            "name": "Observe",
            "desc": "Observes an attribute on an instance.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<any>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 68,
                "path": "src/attributeutils/src/Shared/AttributeValue.lua"
            }
        }
    ],
    "properties": [
        {
            "name": "Value",
            "desc": "The current property of the Attribute. Can be assigned to to write\nthe attribute.",
            "lua_type": "T",
            "source": {
                "line": 78,
                "path": "src/attributeutils/src/Shared/AttributeValue.lua"
            }
        },
        {
            "name": "Changed",
            "desc": "Signal that fires when the attribute changes",
            "lua_type": "Signal<()>",
            "readonly": true,
            "source": {
                "line": 85,
                "path": "src/attributeutils/src/Shared/AttributeValue.lua"
            }
        }
    ],
    "types": [],
    "name": "AttributeValue",
    "desc": "Allows access to an attribute like a ValueObject.\n\n```lua\nlocal attributeValue = AttributeValue.new(workspace, \"Version\", \"1.0.0\")\nprint(attributeValue.Value) --> 1.0.0\nprint(workspace:GetAttribute(\"version\")) --> 1.0.0\n\nattributeValue.Changed:Connect(function()\n\tprint(attributeValue.Value)\nend)\n\nworkspace:SetAttribute(\"1.1.0\") --> 1.1.0\nattributeValue.Value = \"1.2.0\" --> 1.2.0\n```",
    "source": {
        "line": 19,
        "path": "src/attributeutils/src/Shared/AttributeValue.lua"
    }
}