# Replication and Remotes

## Prevent Server Replication

Instances under the Camera Instance in a Server do not replicate to any Clients. This is extremely useful for simulating physics server-side without any clients receiving all that bandwidth.\
\
This has been confirmed by a Roblox staff member to be a supported feature and not just a hack.\
<https://devforum.roblox.com/t/physic-replication-bug-camera-hack-does-not-work-in-all-circumstances-some-data-still-replicates-when-using-certain-instances/2315760/2>

***

## Exclusive Replication

Instances placed under a Player's PlayerGui Instance are only replicated to that specific Player. This is extremely useful for guaranteeing that no one else can touch said instances.\
\
More in-depth blog post: <https://anaminus.github.io/blog/exclusive-replication/>

***

## Guaranteed Replication Order

All remote events, datamodels, and property changes go into the same big interleaved replicated queue. This means that there is a constant guaranteed order to events occurring. For example, you could create an object on the server, then with a remote even tell a client to reference that object on the same frame without issue.

{% hint style="warning" %}
Destroying an Instance will cause any of its changed properties on that frame to not get replicated. This is intentional behaviour: <https://devforum.roblox.com/t/instance-parameters-not-guaranteed-to-be-replicated-before-being-destroyed-yet-children-are/2310933>
{% endhint %}

***

## Replication Speed

Roblox replicates at 20hz. This means that motion of BaseParts involves interpolation. This has subtle implications for different systems, the important being how Servers/Clients see collision.\
\
Because of this: servers cannot reliably guarantee where exactly a Characters location actually is and what exactly it is touching in a given frame.

***

## Parent lastly when creating Instances

A newly created Instance is not considered part of the game until it gets parented for the first time. There are a lot of internal Roblox systems that begin acting on an object the moment it becomes part of the game. This can involve physics, contact states, rendering states, data structure initialization, etc...\
\
The initial setup of an Instances properties are set much more efficiently than if they are changed post being part of the game. This means that most optimal sequence of creating an Instance should look like this:

1. Instance.new()
2. Assign Properties
3. Assign Parent
4. Connect Signals (To guarantee they don't get dispatched during creation)

Source: <https://devforum.roblox.com/t/psa-dont-use-instancenew-with-parent-argument/30296>

***

## Instances are just References

Sending Instances through Remotes is a lot safer than it may appear to be. Remotes will simply turn the instance into a 64 bit referenceID internally and then send that. The receiver will then attempt to find the Instance using that referenceID.

***

## Replication Limitations

Roblox replicates instances at about 10,000 a second.
