> For the complete documentation index, see [llms.txt](https://ans-dev.gitbook.io/datareplicator/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ans-dev.gitbook.io/datareplicator/api-reference/client-side-api/listen.md).

# :Listen

Starts listening for real-time data updates from the server for a specific `realKey`. This is the primary way to create reactive UI and game systems.

This function registers the client with the server for the given key (subject to authorization) and returns a custom [`Signal`](/datareplicator/information/credits-and-acknowledgements.md) object. You can then connect a function to the [.Event](https://create.roblox.com/docs/scripting/events) of this signal to be notified whenever the data is created, updated, or deleted.

***

**`DataReplicator:Listen(realKey: string)`**

***

{% tabs %}
{% tab title="Parameters" %}

* `realKey`: [string](https://create.roblox.com/docs/luau/strings)

  The original data key you want to listen to.
  {% endtab %}

{% tab title="Returns" %}
[`Signal`](/datareplicator/information/credits-and-acknowledgements.md) - A custom Signal object. Connect to its [.Event](https://create.roblox.com/docs/scripting/events) property to receive updates.

* The event fires with the **new data** when it's updated.
* The event fires with **nil** when the data is deleted on the server.
* If data already exists when [`:Listen()`](/datareplicator/api-reference/client-side-api/listen.md) is first called, the event will fire once immediately with the current data.
  {% endtab %}

{% tab title="Example" %}
{% code title="ListenData.luau" %}

```lua
local teamScoreLabel = script.Parent.TeamScoreLabel
local TEAM_SCORE_KEY = "Public_TeamScore_Blue"

-- Start listening for the blue team's score.
local teamScoreSignal = DataReplicator:Listen(TEAM_SCORE_KEY)

-- Connect a function to handle updates.
teamScoreSignal:Connect(function(newScore)
	if newScore then
		-- Update the UI with the new score.
		teamScoreLabel.Text = `Blue Team: {newScore}`
	else
		-- The data was deleted, so we can hide or reset the UI.
		teamScoreLabel.Text = "Blue Team: --"
	end
end)
```

{% endcode %}
{% endtab %}
{% endtabs %}
