ClientRemoteProperty
Created via ClientComm:GetProperty()
.
Properties
Changed
Fires when the property receives an updated value from the server.
clientRemoteProperty.Changed:Connect(function(value)
print("New value", value)
end)
Functions
Get
ClientRemoteProperty:
Get
(
) →
any
Gets the value of the property object.
caution
This value might not be ready right away. Use OnReady()
or IsReady()
before calling Get()
. If not ready, this value will return nil
.
OnReady
ClientRemoteProperty:
OnReady
(
) →
Promise
<
any
>
Returns a Promise which resolves once the property object is ready to be used. The resolved promise will also contain the value of the property.
-- Use andThen clause:
clientRemoteProperty:OnReady():andThen(function(initialValue)
print(initialValue)
end)
-- Use await:
local success, initialValue = clientRemoteProperty:OnReady():await()
if success then
print(initialValue)
end
IsReady
ClientRemoteProperty:
IsReady
(
) →
boolean
Returns true
if the property object is ready to be
used. In other words, it has successfully gained
connection to the server-side version and has synced
in the initial value.
if clientRemoteProperty:IsReady() then
local value = clientRemoteProperty:Get()
end
Observe
Observes the value of the property. The observer will
be called right when the value is first ready, and
every time the value changes. This is safe to call
immediately (i.e. no need to use IsReady
or OnReady
before using this method).
Observing is essentially listening to Changed
, but
also sends the initial value right away (or at least
once OnReady
is completed).
local function ObserveValue(value)
print(value)
end
clientRemoteProperty:Observe(ObserveValue)
Destroy
ClientRemoteProperty:
Destroy
(
) →
(
)
Destroys the ClientRemoteProperty object.