---
title: Player and match persistence in CloudBehaviours
product: Cloud Code
version: 3.0.0
latest_version: 3.0.0
status: This page documents version 3.0.0. The latest version is 3.0.0.
canonical: https://docs.unity.com/en-us/cloud-code/3.0.0/cloudbehaviours/persist-player-and-match-progress
latest_url: https://docs.unity.com/en-us/cloud-code/3.0.0/cloudbehaviours/persist-player-and-match-progress.md
last_updated: 2026-10-23
generated_at: 2026-11-04T18:43:00.630Z
locale: en-us
---

# Player and match persistence in CloudBehaviours

> Understand what Cloud Code persists for a CloudBehaviour between invocations, and how to control it.

> **Important:**
>
> This page describes an experimental feature that might change significantly before release. It's not recommended to use or rely on experimental features in production environments due to potential instability.

Synchronization and persistence are independent. Synchronization controls whether a member reaches a client, and persistence controls whether a member survives between invocations. A member can synchronize, persist, do both, or do neither.

## What persists by default

By default, a public member persists in the cloud between invocations, and a non-public member doesn't. Two attributes override that default, and both attributes apply to fields and properties:

| Attribute                      | Effect                                                                               |
| :----------------------------- | :----------------------------------------------------------------------------------- |
| `[CloudCodeSerializeProperty]` | Persists the member. Use it to persist a non-public member.                          |
| `[CloudCodeIgnoreProperty]`    | Keeps the member out of persistence. Use it to stop a public member from persisting. |

Neither attribute changes whether a member synchronizes. A public member synchronizes and a non-public member doesn't, whichever attribute you apply.

Persistence applies member by member inside a persisted object too. A private field in a persisted custom type needs its own `[CloudCodeSerializeProperty]`.

The following example applies both attributes:

```csharp title="Persistence attributes"
// This field survives invocations, but Cloud Code never sends it to a client.
[CloudCodeSerializeProperty]
private string _correctAnswer;

// This field synchronizes for display, but Cloud Code doesn't persist it.
[CloudCodeIgnoreProperty]
public int FramesSinceStart;
```

## Player scope compared with session scope

`Scope.Player` gives you one CloudBehaviour instance per player, bound to the player's Unity Gaming Services (UGS) identity. Use `Scope.Player` for progression, inventory, and other state that outlives a single session.

`Scope.MultiplayerSession` gives you one instance shared by everyone in a session. Use `Scope.MultiplayerSession` for match state, such as turn order and shared scores, that only needs to last for the session.

Scopes and their lifetimes come from the underlying Stateful Cloud Code module. For the full serialization mechanics, refer to [State serialization in Cloud Code](../modules/stateful-cloud-code/state-serialization).

## Common persistence mistakes

Cloud Code saves only serialized members. A plain private field without `[CloudCodeSerializeProperty]` can keep its value temporarily. However, the field resets whenever Cloud Code reloads your CloudBehaviour from saved state, which can happen between any two calls. If a value unexpectedly resets, confirm that the member is public or marked with `[CloudCodeSerializeProperty]`.

A get-only or computed property that Cloud Code persists, such as `public int Total => A + B;`, causes a compile-time error. Cloud Code can't restore a value into a property without a setter. Exclude the property with `[CloudCodeIgnoreProperty]`, or give it a setter. A private setter is enough.

## Additional resources

* [Synchronized state in CloudBehaviours](./synchronized-state.md)
* [Timers in CloudBehaviours](./timers.md)
* [State serialization in Cloud Code](../modules/stateful-cloud-code/state-serialization)
