Skip to main content

ClientRemoteProperty

This item only works when running on the client. Client

The clientside counterpart of RemoteProperty. A client remote property in layman's terms is just an object connected to a remote property.

Types

ClientRemoteProperty

type ClientRemoteProperty = ClientRemoteProperty

Properties

onUpdate

Read onlySignalClientRemoteProperty instance
ClientRemoteProperty.onUpdate: Signal<newValueany,oldValueany>

A signal which is fired, whenever the value of the remote property (or the value of the client stored in the remote property) is updated.

Incase the client has a specific value set for them in the remote property, then this signal will only fire if that value has been updated.

Functions

is

ClientRemoteProperty.is(selfany) → boolean

Returns a boolean indicating if self is a client remote property or not.

get

ClientRemoteProperty instance
ClientRemoteProperty:get() → T

Returns the value of the client stored in the remote property. If there is no value stored specifically for the client, then the remote property's current value will be returned instead.

observe

ClientRemoteProperty instance
ClientRemoteProperty:observe(callback(
newValueT,
oldValueT?
) → ()) → ()

Observes the value of the client remote property.

clientRemoteProperty:observe(function(newValue, oldValue)
	
end)

valuePromise

ClientRemoteProperty instance
ClientRemoteProperty:valuePromise(valuePredicate((
newValueT,
oldValueT?
) → boolean)?) → ()

Returns a promise which is resolved with a non-nil value of the client remote property, given that valuePredicate is not passed as an argument.

clientRemoteProperty:valuePromise():andThen(function(value)
	print(value) 
end)

valuePredicate can ALSO be passed, which allows you to filter out values. If it returns exactly true, only then will the promise resolve with the new value.

clientRemoteProperty:valuePromise(function(newValue, oldValue) 
	print(newValue, oldValue)
	return oldValue == 1
end):andThen(function(value)
	print(value) 
end)

clientRemoteProperty:set(1) 
clientRemoteProperty:set(2) 

-- Output:
-- 1, nil
-- 2, 1
-- 2

set

ClientRemoteProperty instanceDeprecated
ClientRemoteProperty:set(valueT) → ()

Invokes the remote property, to set the value for the client to value.

Possible rate limit

It is possible that the client may be rate limited by the server (see RemoteProperty:setRateLimitForClientSettingValue), and thus requests to the server to set the value for the client can possibly be ignored by the server.

-- Server
remoteProperty:setRateLimitForClientSettingValue(client, 30) -- 30 seconds

-- Client
clientRemoteProperty.onUpdate:Connect(function(newValue)
	print(newValue) 
end)

-- Spam the setting of value for the client, so we ought for the value of the 
-- client stored in the remote property (finally) to be `100`, but instead
-- it will be `1`, as subsequent calls after the first one will be ignored
-- due to the rate limit imposed.
for index = 1, 100 do
	clientRemoteProperty:set(index)
end

--> 1 
Possible Value Set Request Rejection From Server

The server can decline the client's request of setting the value for the client in the remote property. This behavior will be seen by default, if the remote property has no clientSet middleware - see DefaultRemotePropertyMiddleware and RemotePropertyMiddleware for more info.

setPromise

ClientRemoteProperty instanceDeprecated
ClientRemoteProperty:setPromise(valueT) → Promise<T>

Works the same as ClientRemoteProperty:set, but returns a promise which is resolved when the server has set the value for the client to value, or else rejects with a nil value. Additionally, the returned promise resolves with the value that was set. If this method is called againand the returned promise had not yet finished, then the old promise returned will be cancelled.

Precaution

This method performs a shallow check (self:get() == value) before informing the server to actually set the value. This is an attempt to avoid sending unnecessary requests to the server. For e.g:

local thisValue = {1,2,3}
clientRemoteProperty:setPromise(thisValue):expect() -- Assuming this is successful....
warn(clientRemoteProperty:setPromise(thisValue):expect()) -- Does not inform the server, immediately returns a resolved promise!
Possible Promise rejection

This promise can also be rejected with a nil value if the server declines the client's request of setting the value for the client in the remote property. This behavior will be seen by default, if the remote property has no clientSet middleware - see DefaultRemotePropertyMiddleware and RemotePropertyMiddleware for more info.

-- Client
clientRemoteProperty:setPromise(10):andThen(function(newValue)
	-- Success!
	print(newValue) --> 10
end):catch(function()
	-- Server rejected the request
end)

destroy

ClientRemoteProperty instance
ClientRemoteProperty:destroy() → ()

Destroys the client remote property and renders it unusable.

Show raw api
{
    "functions": [
        {
            "name": "is",
            "desc": "Returns a boolean indicating if `self` is a client remote property or not.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 57,
                "path": "src/network/client/ClientRemoteProperty.luau"
            }
        },
        {
            "name": "get",
            "desc": "Returns the value of the client stored in the remote property. If there is no value stored specifically for the client, \nthen the remote property's current value will be returned instead.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "T\n"
                }
            ],
            "function_type": "method",
            "tags": [
                "ClientRemoteProperty instance"
            ],
            "source": {
                "line": 68,
                "path": "src/network/client/ClientRemoteProperty.luau"
            }
        },
        {
            "name": "observe",
            "desc": "Observes the value of the client remote property. \n\n```lua\nclientRemoteProperty:observe(function(newValue, oldValue)\n\t\nend)\n```",
            "params": [
                {
                    "name": "callback",
                    "desc": "",
                    "lua_type": "(newValue: T, oldValue: T?) -> ()"
                }
            ],
            "returns": [],
            "function_type": "method",
            "tags": [
                "ClientRemoteProperty instance"
            ],
            "source": {
                "line": 84,
                "path": "src/network/client/ClientRemoteProperty.luau"
            }
        },
        {
            "name": "valuePromise",
            "desc": "Returns a promise which is resolved with a non-nil value of the client remote property, given\nthat `valuePredicate` is not passed as an argument.\n\n```lua\nclientRemoteProperty:valuePromise():andThen(function(value)\n\tprint(value) \nend)\n```\n\n`valuePredicate` can ALSO be passed, which allows you to filter out values. If it returns\nexactly `true`, only then will the promise resolve with the new value.\n\n```lua\nclientRemoteProperty:valuePromise(function(newValue, oldValue) \n\tprint(newValue, oldValue)\n\treturn oldValue == 1\nend):andThen(function(value)\n\tprint(value) \nend)\n\nclientRemoteProperty:set(1) \nclientRemoteProperty:set(2) \n\n-- Output:\n-- 1, nil\n-- 2, 1\n-- 2\n```",
            "params": [
                {
                    "name": "valuePredicate",
                    "desc": "",
                    "lua_type": "((newValue: T, oldValue: T?) -> boolean)?\n"
                }
            ],
            "returns": [],
            "function_type": "method",
            "tags": [
                "ClientRemoteProperty instance"
            ],
            "source": {
                "line": 121,
                "path": "src/network/client/ClientRemoteProperty.luau"
            }
        },
        {
            "name": "set",
            "desc": "Invokes the remote property, to set the value for the client to `value`.\n\n:::warning Possible rate limit\nIt is possible that the client may be rate limited by the server (see [RemoteProperty:setRateLimitForClientSettingValue]), and thus\nrequests to the server to set the value for the client can possibly be ignored by the server.\n\n```lua\n-- Server\nremoteProperty:setRateLimitForClientSettingValue(client, 30) -- 30 seconds\n\n-- Client\nclientRemoteProperty.onUpdate:Connect(function(newValue)\n\tprint(newValue) \nend)\n\n-- Spam the setting of value for the client, so we ought for the value of the \n-- client stored in the remote property (finally) to be `100`, but instead\n-- it will be `1`, as subsequent calls after the first one will be ignored\n-- due to the rate limit imposed.\nfor index = 1, 100 do\n\tclientRemoteProperty:set(index)\nend\n\n--> 1 \n```\n:::\n\n:::warning Possible Value Set Request Rejection From Server\nThe server can decline the client's request of setting the value for the client in the remote property. This behavior\nwill be seen by default, if the remote property has no `clientSet` middleware - see [DefaultRemotePropertyMiddleware] \nand [RemotePropertyMiddleware] for more info.\n:::",
            "params": [
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "T"
                }
            ],
            "returns": [],
            "function_type": "method",
            "tags": [
                "ClientRemoteProperty instance",
                "Deprecated"
            ],
            "source": {
                "line": 165,
                "path": "src/network/client/ClientRemoteProperty.luau"
            }
        },
        {
            "name": "setPromise",
            "desc": "Works the same as [ClientRemoteProperty:set], but returns a [promise](https://eryn.io/roblox-lua-promise/) which is resolved **when**\nthe server has set the value for the client to `value`, or else rejects with a `nil value`. Additionally, the returned promise \nresolves with the value that was set. If this method is called againand the returned promise had not yet finished, then the old \npromise returned will be cancelled.\n\n:::note Precaution\nThis method performs a shallow check (`self:get() == value`) before informing the server to actually\nset the value. This is an attempt to avoid sending unnecessary requests to the server. For e.g:\n\n```lua\nlocal thisValue = {1,2,3}\nclientRemoteProperty:setPromise(thisValue):expect() -- Assuming this is successful....\nwarn(clientRemoteProperty:setPromise(thisValue):expect()) -- Does not inform the server, immediately returns a resolved promise!\n```\n:::\n\n:::warning Possible Promise rejection\nThis promise can also be rejected **with a nil value** if the server declines the client's request of setting the value for the client\nin the remote property. This behavior will be seen by default, if the remote property has no `clientSet` middleware - see [DefaultRemotePropertyMiddleware]\nand [RemotePropertyMiddleware] for more info.\n\n```lua\n-- Client\nclientRemoteProperty:setPromise(10):andThen(function(newValue)\n\t-- Success!\n\tprint(newValue) --> 10\nend):catch(function()\n\t-- Server rejected the request\nend)\n```\n:::",
            "params": [
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "T"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<T>"
                }
            ],
            "function_type": "method",
            "tags": [
                "ClientRemoteProperty instance",
                "Deprecated"
            ],
            "source": {
                "line": 218,
                "path": "src/network/client/ClientRemoteProperty.luau"
            }
        },
        {
            "name": "destroy",
            "desc": "Destroys the client remote property and renders it unusable.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "tags": [
                "ClientRemoteProperty instance"
            ],
            "source": {
                "line": 270,
                "path": "src/network/client/ClientRemoteProperty.luau"
            }
        }
    ],
    "properties": [
        {
            "name": "onUpdate",
            "desc": " \n\nA [signal](https://sleitnick.github.io/RbxUtil/api/Signal/) which is fired, whenever the value \nof the remote property (or the value of the client stored in the remote property)\nis updated.\n\nIncase the client has a specific value set for them in the remote property, then this signal\nwill only fire if *that* value has been updated.",
            "lua_type": "Signal <newValue: any, oldValue: any>",
            "tags": [
                "Read only",
                "Signal",
                "ClientRemoteProperty instance"
            ],
            "source": {
                "line": 23,
                "path": "src/network/client/ClientRemoteProperty.luau"
            }
        }
    ],
    "types": [
        {
            "name": "ClientRemoteProperty",
            "desc": " ",
            "lua_type": "ClientRemoteProperty",
            "source": {
                "line": 28,
                "path": "src/network/client/ClientRemoteProperty.luau"
            }
        }
    ],
    "name": "ClientRemoteProperty",
    "desc": "The clientside counterpart of [RemoteProperty]. A client remote property \nin layman's terms is just an object connected to a remote property.",
    "realm": [
        "Client"
    ],
    "source": {
        "line": 8,
        "path": "src/network/client/ClientRemoteProperty.luau"
    }
}