ListenPropertyChange

Constructor:

ListenPropertyChange(tarobject,propertyKey,handle)

Description

Monitors the given property and executes the given function when the property changes.

Parameter

Name Class Name Description
tarobject RWObject The monitored object.
propertyKey string Property name
handle function Function that is executed when the property changes

Examples

Register the part in the method to monitor the Scale property of the part. After Scale changes, observe whether the log is printed or not.

local part = RWObject.Create("Part") -- create a part
part.Position = Vector3.New(2, 1, 0) -- assign a vector to the part position
local function handle(property, value, newValue, objectName, objectClassName) -- define a method of property changing
    print("property " .. property .. " Value Changed")
end
PropertyWatcherService:ListenPropertyChange(part, "Scale", handle) -- register the event that the part property changes
part.Scale = Vector3(0.5,0.5,0.5) -- assign a vector to the part Scale property