Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.