The Problem
If you’ve worked with StreamingEnabled, one thing you may have noticed is that your cutscenes or custom freecam won’t load nearby terrain and instances because of ReplicationFocus. By default, it’s set to the player’s character and that’s problematic because your camera isn’t always near the character when you run a cutscene or go into your custom freecam.
You can tell others have ran into this problem in the past:
The Solution
So, what is the solution to this problem? Well, the solution that I came up with is one where the server creates a part for a player and its client handles moving the part to the player’s camera. Don’t worry if you’re confused, you can find a step-by-step breakdown of this solution below.
How It Works
→ The client asks the server to create a part that will be used as the ReplicationFocus
→ The server creates the part, gives it a tag that the client listens to, sets its name to the player’s UserId, anchors it, and moves it to their character or their current camera CFrame
→ When the part streams in, the client will starting moving the part to the current camera CFrame and then ask the server to unanchor the part and give it network ownership
→ The server receives the request and unanchors the part and gives the player network ownership
→ The client asks the server to cleanup the part when it’s done with it
→ The server destroys the part and sets the ReplicationFocus back to the character
With this solution, even though you’re constantly setting the part’s CFrame, you’re not constantly firing a RemoteEvent for updating the part. Remember, the network ownership belongs to the client and that’s what allows the changes on the client to replicate to the server and other clients.
Available for Free
This resource can be as used either a starting point to solving your problem or maybe even the solution to your problem! The provided package has the client ask for a ReplicationFocus part only when the player’s camera has its CameraType
set to Enum.CameraType.Scriptable
!
If you’re worried about the player’s character falling to their death when the ReplicationFocus is far from its character, you shouldn’t need to. I’ve considered this and it looks like the player’s character freezes in the air when this happens, so they shouldn’t fall to their death.
Known Issues
- The provided package does not account for when a player moves the ReplicationFocus part below the destroy height. This means that it is rare, but possible for the part to be destroyed due to this. If that happens, the code should not break, but the ReplicationFocus will get set back to the character.
- The provided package doesn’t work with the built-in freecam because it keeps the
CameraType
atEnum.CameraType.Custom
. You will more than most likely need to make your own freecam or fork the built-in freecam. - Hopping over to the server view while in Play Solo will cause the part to fall below the destroy height because the client is no longer sending information to the server. This is presumeably a quirk of using Play Solo.
Setup
- Download the .rbxm file attached below or take the free model linked below
- Insert the model into ReplicatedStorage