Property Service v1.0.0 - Advanced property tracking system

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.


:inbox_tray: 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 for number properties
  • VectorThreshold – minimum magnitude diff for Vector2/Vector3
  • UDim2Threshold – minimum per component diff for UDim2
  • CFramePositionThreshold – minimum positional diff (studs) for CFrame
  • CFrameOrientationThreshold – minimum angular diff (degrees) for CFrame 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 names
    • ExcludeList: {string} β€” explicitly exclude these property names
    • MaxPropertyHistory: number β€” override the module default
    • MaxTimelineEntries: 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) that instance: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 was value seconds ago.
  • "Step": Restores the value from value ago from the UndoStack

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 (not OnPropertyChanged) 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

Goodsignal by @stravant


Any feedback, bug reports, or feature requests are welcome!

7 Likes