Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can you send required ModuleScripts through RemoteFunctions without loss of functions?

Asked by 7 years ago

For example, I have a ModuleScript with variables and functions in the server, and I send the require() through the client, will it lose data?

1 answer

Log in to vote
3
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
7 years ago
Edited 7 years ago

Values sent over the network through RemoteFunctions and RemoteEvents are transferred in a format similar to JSON.

The values that are transferable are of several forms:

  • strings
  • numbers
  • booleans
  • ROBLOX values like Vector3, CFrame, BrickColor, and Enums
  • arrays (tables with consecutive indices 1, 2, 3, ...) containing transferable values
  • dictionaries (tables with only string keys) containing transferable values

Note also that references are not preserved, so, e.g., cyclical tables cannot be sent, and objects that were the same object before being transferred will be different objects after being received.

Things that you cannot send include objects with metatables, objects with non-string, non-integer keys, objects with mixed integer and string keys, functions, and coroutines.


There is no practical way to send a function across the network. For example,

local x = 5
local v = function()
    x = x + 1
end

remote:InvokeServer(v)

This is very problematic. If the server were to call the function, then the value of x on the client would change. There is no sane way that this could be made possible.

Ad

Answer this question