# Always getting the error, TypeError: r is null, even when copying code directly from the Documentation

**URL:** <https://narrat.discourse.group/t/always-getting-the-error-typeerror-r-is-null-even-when-copying-code-directly-from-the-documentation/216>\
**Category:** Help\
**Created:** [5 June 2024 20:02 UTC](https://narrat.discourse.group/t/always-getting-the-error-typeerror-r-is-null-even-when-copying-code-directly-from-the-documentation/216 "2024-06-05T20:02:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![C\_C](https://yyz2.discourse-cdn.com/free1/user_avatar/narrat.discourse.group/c_c/32/312_2.png) [@C\_C](https://narrat.discourse.group/u/C_C)\
**Post date:** [5 June 2024 20:02 UTC](https://narrat.discourse.group/t/always-getting-the-error-typeerror-r-is-null-even-when-copying-code-directly-from-the-documentation/216/1 "2024-06-05T20:02:31Z")

</div>

I am trying to follow the examples found here: https://docs.narrat.dev/scripting/language-syntax.htm

But in every example where I try to call a variable I get an error TypeError: r is null

For example when I use this code:

```auto
main:
  set data.player.name "Alice"
  set data.player.age 25
  "The player's name is %{data.player.name} and they are %{data.player.age} years old"

```

Gives me this error:  
**Narrat script runtime error at game.narrat:4**  
**TypeError: r is null**  
**Script : “The player’s name is %{data.player.name} and they are %{data.player.age} years old”**  
**Label: main**

Copying this code

```auto
main:
  set data.player.inventory (new Array "Sword" "Shield" "Potion")
  var array_contents (array_join $data.player.inventory)
  "Your inventory contains %{array_contents}"

```

Gives me the same error as above except this line:  
**Script: “Your inventory contains %{array\_contents}”**

- :browser: : Which browser? :firefox:

---

<div class="post-metadata">

**Author:** ![Narrat-Admin](https://yyz2.discourse-cdn.com/free1/user_avatar/narrat.discourse.group/narrat-admin/32/429_2.png) [@Narrat-Admin](https://narrat.discourse.group/u/Narrat-Admin)\
**Post date:** [5 June 2024 22:08 UTC](https://narrat.discourse.group/t/always-getting-the-error-typeerror-r-is-null-even-when-copying-code-directly-from-the-documentation/216/2 "2024-06-05T22:08:03Z")

</div>

Use %{$data.player.name}, variables need a $ when you refer to their values. Docs might be outdated

Also looking at the default game script that’s in the engine (and linked in a few places in the docs I think) can be a good way to find working examples of syntax since it’s used for testing and has a bit of everything
