Game Content Streaming
Game Content Streaming
Game content streaming allows the Roblox engine to dynamically load and unload assets in regions of the world. This can improve the overall game experience in several ways, for example:
- Faster Load Times — Players can start playing as soon as part of the world is loaded while more of the world loads in the background.
- Wider Device Support — Games can be played on devices with less memory since content is dynamically streamed in and out.
- Terrain Level-of-Detail — Distant terrain landmarks will be visible through lower-detail meshes even before they are fully streamed in.
Enabling content streaming is as simple as enabling StreamingEnabled on the Workspace object in Studio. During all phases of game development, however, be mindful of the following:
- Clients will not typically have the entire
Workspaceavailable locally. Because of this, ensure that all
LocalScript|LocalScriptsfunction correctly by using
Instance/WaitForChild|Instance:WaitForChild()for objects that are necessary within the script.
Instance/WaitForChild|WaitForChild()calls if the script cannot afford to wait indefinitely, for example
If you move a player’s character by setting its
datatype/CFrame|CFrame, doing so from a server-side
Scriptin favor of a
LocalScriptwill let the server more quickly load data around the character’s new location.
Avoid parenting a part to another part rather than a model, especially when the parent is far away from the child. This can result in parts not streaming in when expected.
Manually setting the player’s
Player/ReplicationFocus|ReplicationFocusshould only be done in unique cases like in games that don’t use a
Player/Character|Player.Character. In such cases, make sure the focus is near the object(s) that the player controls to ensure content continues to stream around the player’s interaction point.
The following properties control if and how content streaming will apply to your game. All of these properties are non-scriptable and must be set on the Workspace object in Studio.
Workspace/StreamingEnabled|StreamingEnabled property controls whether the game should utilize content streaming.
Workspace/StreamingMinRadius|StreamingMinRadius indicates the radius around the player’s character (or the
Player/ReplicationFocus|ReplicationFocus) in which content will be streamed in at the highest priority.
Workspace/StreamingTargetRadius|StreamingTargetRadius property controls the maximum distance away from the player’s character (or the
Player/ReplicationFocus|ReplicationFocus) in which content will be streamed in. Note that the engine is allowed to retain previously loaded content beyond the target radius, memory permitting.
Your game may behave in unintended ways if a player somehow moves into a region of the world that hasn’t been streamed to them. The streaming pause feature helps manage this by pausing the local physical simulation and normal character movement if content within
Workspace/StreamingMinRadius|StreamingMinRadius isn’t yet streamed in. Non-physical systems will continue to run (scripts will continue executing, for example) and gameplay will resume after the engine has loaded enough content to minimize further pauses.
Workspace/StreamingPauseMode|StreamingPauseMode property controls the pause behavior as follows:
|ClientPhysicsPause||Client physics will pause until sufficient regions are streamed in.|
|Default||Currently equal to Disabled but the default will become ClientPhysicsPause in the future.|
|Disabled||No change to physical processing even if players are outside streamed-in regions. This may result in players falling through the world if network conditions are poor.|
If you set the
datatype/CFrame of a player to a region which isn’t currently loaded, streaming pause (if enabled) will occur. If you know the player will be moving to a specific area, you can call
Player/RequestStreamAroundAsync|RequestStreamAroundAsync() to request that the server sends regions around that location to the client.
The following scripts show how to fire a client-to-server
articles/Remote Functions and Events|remote event to teleport a player within a place, yielding at the streaming request before moving the character to a new
Requesting streaming around an area is not a guarantee that the content will be present when the request completes, as streaming is affected by the client’s network bandwidth, memory limitations, and other factors.
Customizing the Pause Screen
Player/GameplayPaused|Player.GameplayPaused property indicates the player’s current pause state. This property can be used with a
Instance/GetPropertyChangedSignal|GetPropertyChangedSignal() connection to show or hide a custom GUI.