ReplicatedStorage
ReplicatedStorage : Instance
Overview
The ReplicatedStorage class is a container service that allows developers to store objects that need to be accessible by both the server and clients. It is primarily used for sharing assets, scripts, and data between the server and connected players. Objects placed in ReplicatedStorage are automatically replicated to all clients, making it an ideal location for storing resources like RemoteEvents, RemoteFunctions, ModuleScripts, models, and other shared content.
Description
The ReplicatedStorage service provides a centralized storage solution for objects that require simultaneous access by both the server and clients. This makes it a critical component for implementing client-server communication, sharing reusable assets, and optimizing game performance by preloading commonly used resources.
Key Features
Shared Access:
Objects stored in
ReplicatedStorage
are available to both the server and all connected clients. This ensures that both sides can access the same resources without duplicating them.
Replication Rules:
Changes made to objects in
ReplicatedStorage
on the server are replicated to all clients.Changes made on the client persist locally but are not replicated back to the server or other clients.
Script Behavior:
Scripts placed in
ReplicatedStorage
do not execute automatically. Developers must explicitly require or load them into appropriate locations (e.g., workspace or player scripts) for execution.
Use Cases:
Storing shared assets like models, animations, or sounds.
Housing
RemoteEvents
andRemoteFunctions
for client-server communication.Keeping reusable
ModuleScripts
accessible to both server-side and client-side scripts.
Common Use Cases
Client-Server Communication:
Store
RemoteEvents
andRemoteFunctions
for handling interactions between clients and the server.
Asset Preloading:
Place models, sounds, or other assets in
ReplicatedStorage
to ensure they are available to all clients without delays.
Shared Scripts:
Use
ModuleScripts
inReplicatedStorage
to provide reusable code libraries for both server-side and client-side scripts.