Client Client Only Since 1.0.0
The client namespace object. This object is returned by Red.Client
and is used for networking on the client.
Methods
Fire Client Only Since 1.0.0
Fires an event to the server.
(
Event: string, -- The name of the event to fire.
...: any -- The arguments to pass to the event.
) -> Promise
WARNING
This method has the same data limits as RemoteEvent
. Any data that cannot be serialized will arrive malformed on the server.
local Net = Red.Client("NamespaceName")
Net:Fire("EventName", "Hello, world!")
Call Client Only Since 1.0.0
Calls a function on the server.
(
Event: string, -- The name of the event to fire.
...: any -- The arguments to pass to the event.
) -> Promise
This calls the connected function.
WARNING
This method has the same data limits as RemoteEvent
. Any data that cannot be serialized will arrive malformed on the server.
local Net = Red.Client("NamespaceName")
local Response = Net:Call("EventName", "Hello, world!")
On Client Only Since 1.0.0
Connects a function to an event.
(
Event: string, -- The name of the event to connect to.
Callback: (...any) -> () -- The function to connect.
) -> Promise
local Net = Red.Client("NamespaceName")
Net:On("EventName", function(...)
print(...)
end)
Folder Client Only Since 1.0.0
Retrieves the shared folder that replicates from the server to the clients.
() -> Folder
Yielding Behavior
This method will only yield if the namespace folder is not yet loaded on the client. This function will infinitely yield if the namespace folder is not created on the server.
local Net = Red.Client("NamespaceName")
local Folder = Net:Folder()
print(Folder:GetAttribute("Hello"))
LocalFolder Client Only Since 1.0.0
Retrieves the folder that replicates from the server to this client.
() -> Folder
Any data in this folder is privately replicated only to this client.
Yielding Behavior
This method will only yield if the namespace folder is not yet loaded on the client. This function will infinitely yield if the namespace folder is not created on the server.
How is this possible?
Folders that replicate to single players are done by using their PlayerGui. Anything there is replicated to that player only. Red cleans up the folder so you will find no trace of it in the PlayerGui.
local Net = Red.Client("NamespaceName")
local Folder = Net:LocalFolder()
print(Folder:GetAttribute("Hello"))