Skip to main content

instancePropertyUtil

An utility module for working with instance properties.

Functions

setInstanceProperties

instancePropertyUtil.setInstanceProperties(
instanceInstance,
properties{[string]any},
tweenInfoTweenInfo?
) → Tween?

Sets the properties of instance from the properties table.

instancePropertyUtil.setInstanceProperties(workspace.Baseplate, {Transparency = 1})
print(workspace.Baseplate.Transparency) --> 1

local tween = instancePropertyUtil.setInstanceProperties(workspace.Baseplate, {Transparency = 0}, TweenInfo.new(5))
tween.Completed:Wait()

observeProperty

instancePropertyUtil.observeProperty(
instanceInstance,
propertystring,
observer(
newValueany,
oldValueany
) → ()
) → RBXScriptConnection

Observes the given property of the instance. observer will be called initially, being passed the current value of the property. As the property updates, observer will be called being passed both the new value of the property and the old value.

instancePropertyUtil.observeProperty(workspace.Baseplate, "Anchored", function(newPropertyValue, oldPropertyValue)
	print(newPropertyValue, oldPropertyValue)
end)
Show raw api
{
    "functions": [
        {
            "name": "setInstanceProperties",
            "desc": "Sets the properties of `instance` from the `properties` table.\n\n```lua\ninstancePropertyUtil.setInstanceProperties(workspace.Baseplate, {Transparency = 1})\nprint(workspace.Baseplate.Transparency) --> 1\n\nlocal tween = instancePropertyUtil.setInstanceProperties(workspace.Baseplate, {Transparency = 0}, TweenInfo.new(5))\ntween.Completed:Wait()\n```",
            "params": [
                {
                    "name": "instance",
                    "desc": "",
                    "lua_type": "Instance"
                },
                {
                    "name": "properties",
                    "desc": "",
                    "lua_type": "{ [string]: any }"
                },
                {
                    "name": "tweenInfo",
                    "desc": "",
                    "lua_type": "TweenInfo?\n"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Tween?\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 22,
                "path": "src/instancePropertyUtil/init.luau"
            }
        },
        {
            "name": "observeProperty",
            "desc": "Observes the given property of the instance. `observer` will be called initially, being passed\nthe current value of the property. As the property updates, `observer` will be called being passed\n*both* the new value of the property *and* the old value.\n\n```lua\ninstancePropertyUtil.observeProperty(workspace.Baseplate, \"Anchored\", function(newPropertyValue, oldPropertyValue)\n\tprint(newPropertyValue, oldPropertyValue)\nend)\n```",
            "params": [
                {
                    "name": "instance",
                    "desc": "",
                    "lua_type": "Instance"
                },
                {
                    "name": "property",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "observer",
                    "desc": "",
                    "lua_type": "(newValue: any, oldValue: any) -> ()\n"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "RBXScriptConnection\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 52,
                "path": "src/instancePropertyUtil/init.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "instancePropertyUtil",
    "desc": " \n\nAn utility module for working with instance properties.",
    "source": {
        "line": 6,
        "path": "src/instancePropertyUtil/init.luau"
    }
}