Server Authority: How to Begin?

Hello :wave:! Today, I’m here to teach you the basics of the new Server Authority system that Roblox has released out of Early Access and into Beta. In this tutorial, I will explain the core concepts behind Server Authority and Rollback Netcode and give you information on how to begin working with it on Roblox. Let’s begin.

How to Enable Server Authority


Before we start this tutorial, you first need to enable the Server Authority Core API beta feature in Roblox Studio. To do this, simply go to “File > Beta Features > Server Authority Core API”, check the box, and click “Save”.

After restart, head over to Workspace, and configure these properties to the required values:

  • Workspace > StreamingEnabled: Enabled
  • Workspace > UseFixedSimulation: Enabled
  • Workspace > PlayerScriptsUseInputActionSystem: Enabled
  • Workspace > NextGenerationReplication: Enabled

Configuring these properties will now allow you to configure another property, which you need for enabling Server Authority:

  • Workspace > Server Authority > AuthorityMode: Server

After configuring the properties above, Server Authority should now be ready for usage.


What is Server Authority?


Server Authority is when the server becomes the only source of truth for game actions, logic and data in your world.

In this model, clients can no longer hold network ownership of any instances. This ensures the trusted data replicated from the client to the server is kept at a minimum. The only trusted data that the server recieves from the clients are their inputs, which is used to simulate their characters or systems controlled by them. This results in a far more secure model, which reduces or outright removes many problems that have arisen from giving clients network ownership of certain parts and systems in your world.

How does this effect the physics around my world?


Server Authority completely changes the behavior of all unanchored Parts in the Workspace. Before; the physics calculation of a Part was handled by both the server and the clients in a place. When a client came close to a Part, the network ownership would automatically shift from the server to the client, so the client could take the burden of calculating the physics for that Part.

A similar case was also in effect for the characters too. Before, because of network ownership, the client had full control over their character. This allowed them to change certain properties of their character such as velocity, position, rotation, and many others to their liking. This of course, caused many security issues. Using exploits, the client would be able to give themselves an unfair advantage in gameplay by changing these properties. This gave the rise of many exploiting issues such as speed-hacking, fly-hacking, no-clipping, teleporting, and many others inside popular places on the platform.

The issues are not only limited to exploiting. In many competitive games, such as racing, the cars would most of the time be misaligned, or their position would constantly jitter, or look very different. That is because of client calculated physics of the previous system. Because the network ownership of each car is set to each client, rather than the server, the car positions would end up different than expected.

However, with Server Authority, most of these issues, if not all of them, are automatically resolved.

For the case of the character, where a client would modify their character to gain an unfair advantage such as speedhacking, would no longer be possible, as the client no longer holds ownership of their character, and all that is given to the server are inputs.

For the case of the racing games, since the server now calculates the positions of the cars, they now move more consistently. Maneuvers, drifts, hits become more accurate, and the system works as smooth as possible.


The Problem with Server Authority


For the reasons I’ve given above, Server Authority sounds amazing, it improves accuracy, increases security and overall produces a better experience for players, right? Not exactly.

Server Authority on its own is horrible for player experience. This is simply due to the fact that players are from all around the world, where they might be hundereds, if not thousands of miles away from the nearest server. This distance means their ping will be high, which means the time it will take for a player’s input to reach the server will also be high. This creates a choppy, very uncomfortable experience where a player might only start seeing their character move after a long time has passed since they sent their input. Imagine pressing the “W” key and only seeing your character move after a second or two. It would make it incredibly hard to play a game, if not outright impossible for some players.

Luckily, there is a solution that exists which solves these problems. This solution has existed for a very long time, and many competitive games out there already use it. It is called “Rollback Netcode”.


What is Rollback Netcode?


To give a short explanation on what Rollback Netcode is, this concept is when the client also simulates its own input alongside the server, but just a little bit ahead of it. For the inputs to feel responsive and smooth, the client immediately simulates them when they are given, while sending them to the server. Since the server is the authority here, this simulation doesn’t hold an important value, and is purely done for the visuals, so we call them "prediction"s. Essentially, the client “predicts” how their inputs will effect the game state (e.g, their character), while the server determines how their inputs will actually effect the game state.

However, there might be times where the client prediction and the actual simulation results may differ from each other. For example, assuming T is the current time, the client has made a prediction at T-3, and when the authoritative update arrives for T-3 from the server, the client notices its prediction and the authoritative update results are different from each other. This is called a “Misprediction”. In this case, the client rolls back to the authoritative update frame by reverting its current state and time. This is called a “Rollback”. Then, the client re-simulates automatically after rollback to speed back to its current predicted frame. The number of frames to re-simulate is based on the latency between the client and the server, however, the client tries to stay far enough ahead of the server so that its own inputs arrive on the server just in time to be processed on the frame the player intended to perform them.

Mispredictions are normal and expected. They should be small and the resulting correction should be imperceptible to clients.

(You can check out articles on the web, such as this one, to learn more about the concept of Rollback Netcode.)


Example:

Your client thinks you’ve moved forward. However, the server registered that you were hit by a stun grenade and can’t move for a few seconds. The client and server now have different states.


Like I have mentioned above, this divergence is called a misprediction. It can occur for several reasons: the network latency has shifted, other players acted in ways the client didn’t anticipate, the experience runs certain logic exclusively on the server, etc. While you can’t prevent every misprediction, you can keep gameplay feeling smooth and responsive by using the right techniques.


Example:

Let’s say there is 100ms of latency between the client and server, and the experience is a 60Hz game.


Each frame is 1/60s (or 16.67ms). Since 100ms of latency is equivalent to ~6 frames (100 ms divided by 16.67 ms/frame), we know the client will be 6 frames ahead of the server. This means that, when the client detects it made a misprediction, it will rollback to the server’s state and then re-simulate 6 frames ahead. In general, the player should hardly notice this.


How can I start working with Server Authority on Roblox?


Now that we have learned the basic concepts, we can now move on to learning how to actually apply these concepts on Roblox. To begin, we first need to talk about IAS.

The Input Action System


The Input Action System (IAS) is a major part of the Server Authority system. It allows you to reliably transfer inputs from client to the server, while allowing you to customize them easily. I will not be explaining this system and how it works however. You can check out the main post talking about it through here.

Player inputs like joystick movement and button presses are sent from client to server using InputActions. You have to use InputAction for all inputs that affect the core game simulation, because they are the only client authoritative data in the core rollback system.

You can send any continuous stream of data from the client to server using this API, and the server will trust what the client has sent. It is up to you to validate that the clients have sent legitimate inputs. Be sure to enforce maximum and minimum ranges on numbers sent from the client, just like how you would validate values sent from remotes.

:warning: Note: The server will automatically ignore input data from the client if it arrives far too late or far too early, which can happen if there are sudden changes in a client’s network conditions.


Now, let’s apply all of the concepts I’ve explained above with IAS on Roblox. We start by using the new methods of RunService.

RunService


RunService:BindToSimulation(function: (deltaTime: number) -> (), frequency: Enum.StepFrequency?)

This method allows you to bind a function to the simulation with a certain amount of frequency. Depending on the frequency, this function will be called with a deltaTime argument. If a frequency argument has not been provided, then it will default to Enum.StepFrequency.Hz60. This is the right place to put your core game logic, including processing input and updating your synchronized game data. This function will also be ran when a rollback occurs.

RunService:SetPredictionMode(context: Instance, mode: Enum.PredictionMode)

Determines whether the engine will rollback and resimulate the context Instance.

  • If mode is Enum.PredictionMode.Off: Disables rollback and resimulation for the Instance. When a place’s Workspace.AuthorityMode is set to Server, the Instance will be owned by the server with no client-side prediction.
  • If mode is Enum.PredictionMode.Automatic (default value): Allows the engine to determine whether to rollback and resimulate the Instance. For Instances that derive from BasePart, the engine uses the player’s simulation radius to determine if an Instance should be predicted. This helps limit expensive client-side prediction to only the relevant Instances. At the moment, Non-BaseParts will not rollback when set to Automatic.
  • If mode is Enum.PredictionMode.On: Will ensure the Instance is always rolled back when a misprediction occurs. For Instances critical to your experience, use this setting. Otherwise, do not overuse On for Instances, as it’ll have significant performance implications for low-end devices.

RunService:GetPredictionStatus(context: Instance): Enum.PredictionStatus

This function allows you to check the prediction status of the context Instance. This may be essential for scripts affecting multiple instances (e.g., vehicle controllers, custom physics) where some might be predicted and other might not. It may also be useful for debugging and observing the effects of automatic prediction.


RunService will be our main tool in creating systems with Server Authority and Rollback Netcode. We utilize it to run a functions during simulation on both the Client and the Server.

With RunService:BindToSimulation(), we run our important core game logic on the Server, allowing the Server to be authoritative over this game logic. Like I mentioned in above sections, this can be character or vehicle movement systems, or other logic that is very important to your game. However, for the client to predict these systems to the inputs can remain smooth and responsive, we also need to run the same simulation code on the client.

Essentially, we need to run the same code on both the Client and the Server, using RunService:BindToSimulation(), to apply all of the concepts mentioned above. This ensures the server to stay authoritative, while allowing the client to be more responsive.

To do this easily, we can opt into using a multi-script architecture, where a ModuleScript is parented to a location that is accessible from both the Server and the Client, such as ReplicatedStorage, is required and ran by both the Server and the Client.

Here’s a simple example of this architecture:

image_2

We have two scripts which initialize the “SimulationModule” ModuleScript on both the Server and the Client.

SimulationClient and SimulationServer

require(script.Parent.SimulationModule).Run()

SimulationModule

local RunService = game:GetService("RunService")

local module = {}

function module.Run()
    RunService:BindToSimulation(function(deltaTime: number)
        -- This code will be ran on both the server and the client.
    end)
end

return module

This simple architecture is the foundation of many systems that run on the server-authoritative model. Using this, we can implement many types of systems, such as a character movement system, and more!


Closure


Thank you all for reading this tutorial, if you have any suggestions or feedback, please let me know in the replies section. This tutorial was made with the information that I have compiled in my own documentation, which can be found here. It also includes examples of systems which you can create with Server Authority, such as an admin commands system with a Fly command.

I would also like to thank everyone who gave me additional information about this system, without all of that information, I wouldn’t have been able to create this tutorial this early. Thank you.

96 Likes

Well done :clap:

you really came at the PERFECT time.

4 Likes

IS IT OUT OF BETA!?
FINALLY MY GAME CAN HAVE FALL DAMAGE :fire::fire::fire:
This stuff lowkey fire

4 Likes

NOTE: if you’re testing the new server authority out, and you’re wondering why it’s so laggy: It’s because you’re running the server and the client on one application.

Instead, change the testing mode to “Server & Clients”
Set the Client count to 1
and THEN test.

It was horrifically jittery before, but after changing the test settings, it’s completely fine.
Hope this helps anybody else confused :smiley:

16 Likes

I would like to add to this tutorial that you please watch closely for the API changes. Server authority is still going to change vastly despite the contradicting beta release, which means what might be the solution now will not be a good solution in future releases.

I and Noctua have been watching this feature closely for the past year. And we can confirm that it went through at least 4 significant phases:

  • Chickynoid-alike - very and very early server authority implementation derived from chickynoid as a proof of concept. it involved PlayerData instances. Not much known except that it’s api was very similar to Chickynoid.
  • Aurora phase - it’s not an abandoned concept; they are still working on the Aurora system. We as scrappers thought that’s how server authority is dubbed internally, but recently we found it’s just a separate feature still in the works that “will revolutionize the way you script on roblox.” It still probably was one of the phases that roblox engineers considered as the core API for server authority but was discarded for the initial release.
  • Early-access phase - the basis for the current API we have; not much changed from this point on there. This release exposed basic server authority APIs, such as fixed heartbeat and prediction mode on instances. As far as I remember, only streaming and fixed physics step were forced for this release.
  • Beta-access phase - same as early access except for improved humanoid handling and some changes:

    FixedHeartbeat → BindToSimulation
    ServerFrame → time()

I’ve written the phases above to make you understand that bleeding-edge features are still going to come in hot with this model. As far as I know currently, the server frame property and misprediction event are coming back, and the Aurora system will be released later as an addition for server authority and scripting in general.

6 Likes

All the APIs that are present in RunService today were once inside a test service called AuroraService, it wasn’t a phase, really. They just transferred the APIs over to RunService for production, and removed some of them, even though some of their functionality still exists internally.

Also, “Aurora” is the internal name given to the whole server authority system. It’s ugly, and it shouldn’t be used to describe a phase. That aside, The AuroraScript feature will most likely be rebranded as BehaviorScripts, and hopefully released eventually.

Also I have yet to see evidence an engineer stating the phrase “will revolutionize the way you script on Roblox” about them.

Many of the APIs and the sub-systems the whole Server Authority system relied on did not have user-facing toggles. As far as I’m aware, the forced features have always existed and were on.

3 Likes

What I suspect really happened to the Aurora system was that it was simply moved to a separate system instead of being a general solution to server authority code. That’s why I said that it was rather a dub than an actual name

2 Likes

They said “brand new way”, not revolutionize. Still, thanks for the info, I haven’t seen that reply.

Like I mentioned, “Aurora” is an internal name given to the whole Server Authority system. What you’re describing are AuroraScripts. Which will be actually named as "Behavior"s.

That aside, quite suprising that they thought this will be a brand new way to script on Roblox when in reality it’s a simple module initializer-like system. I wonder what they have in store next.

1 Like

Awesome resource! It helped me understand the concept a bit better.

I noticed a small issue with the example fly script at the bottom of the page. onPlayerAdded yields.

for _, player in Players:GetPlayers() do
    onPlayerAdded(player)
end

Should be:

for _, player in Players:GetPlayers() do
    task.spawn(onPlayerAdded, player)
end

Must StreamingEnabled really be enabled in order to use Server Authority?

1 Like

Yes. StreamingEnabled must be enabled in order for Server Authority to work.

1 Like

I wonder for what reason this has to be done :thinking: I’d like to implement server authority but I don’t want to use streaming for my game’s environments.

1 Like

This one post explains it well.

4 Likes

To be fair i was thinking that that’s it but sadly nope. My movement system is still jittery as heck (velocity based character movement) Even tho prediction runs at 60 CPS it still falls behind a lot (maybe again cuz im using LinearVelocity etc and It just doesn’t work well yet for this usecase :eyes:)

It’s not out of beta apparently, and I would like to know when it can be added to published games.

4 Likes

If anyone wants a practical example, a good one I’ve noticed is in the Strongest Battlegrounds. When you do a body slam and you think you’ve dodged it, you are on the client, so it may look as though you dodged it, but the server will think you were in the hit-radius however many milliseconds ago, so it will “rollback” and seemingly teleport you and ragdoll as if you hadn’t dodged.

1 Like

Its not like that. The Strongest Battlegrounds simply sets your CFrame after body slam, it doesn’t actually rollback.

Not an actual example though, just the data of your character’s position is sent later after your movement and it’s unable to replicate in time + TSB makes sure you are under server’s control when in ragdoll state pretty much, hence the “rollback”.

1 Like

Does anyone know when this is expected to be stable and fully rolled out? There are many games right now that are desperately in need of this.

Source

1 Like