Why can a player set their own score?

They own their pawn, so they own what's synced on it.

Why can a player set their own score?

The problem

The owner writes [Sync].

public class Player : Component{    [Sync] public int Score { get; set; }} // on a modded clientScore = 1000000;

[Sync] carries the owner's value to everyone. The owner of a pawn is the player, so the player decides.

The fix

Let the host own the number.

With SyncFlags.FromHost, only the host can change it. A client's write is ignored.

[Sync( SyncFlags.FromHost )]→the host writes, all read

The fix in code

One flag.

public class Player : Component{    [Sync( SyncFlags.FromHost )]    public int Score { get; set; }} // on the host onlyvoid AddScore( Player p, int pts ) => p.Score += pts;

Our tag game keeps every score this way: the host owns the number and sends it out.

Watch out

A client's write does nothing.

No error, no change. If a client needs it changed, it asks the host.

The host
writes it
Clients
only read it
A client write
ignored, no error

The rule

The rules own it? Sync it from the host.

Player input
[Sync]
Scores, health, rounds
SyncFlags.FromHost
Who writes
the host only