Property Service
Introduction
Property Service is a module that detects changes on any instance`s property, stores a detailed change history, and enables advanced tracking.
Download
Module Link
https://create.roblox.com/store/asset/112688602656334/PropertyService
Handler
Name | Type | Default | Description |
---|---|---|---|
PropertyService.MaxPropertyHistory |
number |
math.huge |
Maximum number of history entries to keep per property. |
PropertyService.MaxTimelineEntries |
number |
math.huge |
Maximum total entries in the shared timeline across all properties. |
PropertyService.Thresholds |
{[string]: number} |
See below | Per type change thresholds (see keys below). |
Thresholds
keys
NumberThreshold
β minimum absolute diff fornumber
propertiesVectorThreshold
β minimum magnitude diff forVector2
/Vector3
UDim2Threshold
β minimum per component diff forUDim2
CFramePositionThreshold
β minimum positional diff (studs) forCFrame
CFrameOrientationThreshold
β minimum angular diff (degrees) forCFrame
orientation
Constructor
PropertyService.new(Instance: Instance, Options: Options?) -> Structure
Instance
(Instance
, required): the object whose properties you wish to track.options
({[string]: any}
, optional):IncludeList: {string}
β explicitly include only these property namesExcludeList: {string}
β explicitly exclude these property namesMaxPropertyHistory: number
β override the module defaultMaxTimelineEntries: number
β override the module default
Returns a Structure
object for further interaction.
Structure properties
Name | Type | Description |
---|---|---|
Instance |
Instance |
The object being monitored. |
Lists |
{[string]: {[number]: Property}} |
Per property arrays of all recorded { Value, Time } entries. |
Timeline |
{[number]: {[string]: Property}} |
Ordered list of { [Property] = { Value, Time } } happenings. |
UndoStacks |
{[string]: {[number]: any}} |
Per property stacks of previous values for undo operations. |
Methods
InitInstance()
PropertyService:InitInstance(Instance: Instance) Structure:InitInstance()
(internal) Sets up
GetPropertyChangedSignal
listeners for the given instance.
GetAllProperties()
PropertyService:GetAllProperties(Instance: Instance): {Property: string} Structure:GetAllProperties(): {Property: string}
Returns a filtered list of property names currently valid on the instance (applies Include/Exclude).
GetStructure()
PropertyService:GetStructure(Instance: Instance): Structure
Returns the existing
Structure
object for an instance.
CastBase()
PropertyService:CastBase(Instance: Instance): {Property: string}
Returns the most specific base class name (from
BaseClasses
) thatinstance:IsA()
GetClassesFromProperty()
PropertyService:GetClassesFromProperty(Property: string): {Class: string}
Returns a list of all
ClassName
in which the given property appears.
Undo()
Structure:Undo(Property: string, Value: number?, Mode: ("Time" | "Step")?)
"Time"
(default): restore the value as it wasvalue
seconds ago."Step"
: Restores the value fromvalue
ago from theUndoStack
UndoAll()
Structure:UndoAll(Value: number?, Mode: ("Time" | "Step")?)
Applies
Undo(...)
to every property being tracked.
MonitorReplication()
Structure:MonitorReplication(Properties: {Property: string})
Begins polling on
RunService.Heartbeat
for replication changes of the listed properties.
- Initializes history for any new or previously untracked properties.
- Fires only
OnReplicatedPropertyChanged
(notOnPropertyChanged
) when thresholds are exceeded, ignoring changes by script within a short grace period.StopMonitoringReplication()
Structure:StopMonitoringReplication()
Stops the polling loop and clears any last value caches used for replication detection.
ClearHistory()
Structure:ClearHistory() Structure:ClearHistory(Property: string)
- Without argument: clear all property histories and timeline.
- With
property
: clear only that propertyβs tracked entries.
Destroy()
Structure:Destroy()
Disconnects all signals, stops monitoring instance and removes the
Structure
from internal storage.
Events
Name | Fires when⦠| Arguments |
---|---|---|
OnPropertyChanged |
Any property is changed. | (Property: string, New: any, Old: { [Property] = { Value, Time } }) |
OnReplicatedPropertyChanged |
Properties tracked by MonitorReplication() are changed. |
(Property: string, New: any, Old: { [Property] = { Value, Time } }) |
Example 1: Detecting changes in part size
--server script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PropertyService = require(ReplicatedStorage:FindFirstChild("PropertyService"))
local part = script.Parent
local storedInstance = PropertyService.new(part, {
IncludeList = {"Size"}
})
storedInstance.OnPropertyChanged:Connect(function(Property, New, Old)
print(Property, New, Old)
end)
Example 2: Detecting changes in CFrame of humanoid root part
--local script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PropertyService = require(ReplicatedStorage:WaitForChild("PropertyService"))
local char = script.Parent
local hrp = char.HumanoidRootPart
local storedInstance = PropertyService.new(hrp)
storedInstance:MonitorReplication("CFrame")
storedInstance.OnReplicatedPropertyChanged:Connect(function(Property, New, Old)
print(Property, New, Old)
end)
Credit
Any feedback, bug reports, or feature requests are welcome!