RequestStreamAroundAsync
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts.
For games where Workspace/StreamingEnabled|StreamingEnabled
is set to true, requests that the server stream to the player regions (parts and terrain) around the specified X, Y, Z location in the game world. It is useful if the game knows that the player’s datatype/CFrame
will be set to the specified location in the near future. Without providing the location with this call, the player may not have streamed in content for the destination, resulting in a streaming pause or other undesirable behavior.
The effect of this call will be temporary and there are no guarantees of what will be streamed in around the specified location. Client memory limits and network conditions may impact what will be available on the client.
Usage Precaution
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.
For more details, see the articles/content streaming|Game Content Streaming
article.
Parameters
Name | Type | Default | Description |
---|---|---|---|
|
World location where streaming is requested |
||
0
|
Optional timeout for the request |
Returns
Return Type | Summary |
---|---|
No return |
Code Samples
Streaming Requests
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 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/Remove Functions and Events|remote event
to teleport a player within a place, yielding at the streaming request before moving the character to a new CFrame.
-- Localscript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local teleportEvent = ReplicatedStorage:WaitForChild("TeleportEvent")
local teleportTarget = CFrame.new(50, 2, 120)
-- Fire the remote event
teleportEvent:FireServer(teleportTarget)
-- Server script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local teleportEvent = ReplicatedStorage:WaitForChild("TeleportEvent")
-- Teleport player
local function teleportPlayer(player, teleportTarget)
-- Request streaming around target location
player:RequestStreamAroundAsync(teleportTarget.Position)
-- Teleport character
player.Character:SetPrimaryPartCFrame(teleportTarget)
end
-- Call "teleportPlayer()" when the client fires the remote event
teleportEvent.OnServerEvent:Connect(teleportPlayer)