# Invalid call. Nonexistent function 'authenticate\_email\_async' in base 'Nil'. (BUT EXISTS)

**URL:** <https://forum.heroiclabs.com/t/invalid-call-nonexistent-function-authenticate-email-async-in-base-nil-but-exists/3187>\
**Category:** Game Design\
**Created:** [October 20, 2022, 4:16pm UTC](https://forum.heroiclabs.com/t/invalid-call-nonexistent-function-authenticate-email-async-in-base-nil-but-exists/3187 "2022-10-20T16:16:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sergisnt](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sergisnt/32/1377_2.png) [@sergisnt](https://forum.heroiclabs.com/u/sergisnt)\
**Post date:** [October 20, 2022, 4:16pm UTC](https://forum.heroiclabs.com/t/invalid-call-nonexistent-function-authenticate-email-async-in-base-nil-but-exists/3187/1 "2022-10-20T16:16:44Z")

</div>

Hi guys, I’m implementing my nakama connection system in Godot 4. And currently I’m facing this problem:

When I try to call the “authenticate\_email\_async” function.  
I get this “Invalid call. Nonexistent function ‘intance’ in base ‘Nil’.” It is possible that it is a silly mistake on my part, but I have been googling and I have not found a solution, I leave you the images so that you can see that everything is in order (in my opinion) and that it should be working. Thanks in advance.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/heroiclabs/original/2X/e/ec251eba1beb21b13f46a345b033f84ff4658e01.png)

in Online I have:

```auto
var nakama_client: NakamaClient :
	get:
		return nakama_client # TODOConverter40 Copy here content of get_nakama_client
	set(mod_value):
		mod_value # TODOConverter40 Copy here content of _set_readonly_variable

```

And Online is a singelton.

---

<div class="post-metadata">

**Author:** ![tom](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/tom/32/676_2.png) [@tom](https://forum.heroiclabs.com/u/tom)\
**Post date:** [October 21, 2022, 8:28am UTC](https://forum.heroiclabs.com/t/invalid-call-nonexistent-function-authenticate-email-async-in-base-nil-but-exists/3187/2 "2022-10-21T08:28:53Z")

</div>

Hi @sergisnt,

It looks to me as though your setter is wrong for `nakama_client`. You’re missing the assignment.

```auto
set(mod_value):
  nakama_client = mod_value

```

---

<div class="post-metadata">

**Author:** ![sergisnt](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sergisnt/32/1377_2.png) [@sergisnt](https://forum.heroiclabs.com/u/sergisnt)\
**Post date:** [October 21, 2022, 6:01pm UTC](https://forum.heroiclabs.com/t/invalid-call-nonexistent-function-authenticate-email-async-in-base-nil-but-exists/3187/4 "2022-10-21T18:01:07Z")

</div>

I’ve tried but the error persists…

 ![image](https://us1.discourse-cdn.com/flex020/uploads/heroiclabs/original/2X/a/a040bb28ccccb442d09f7f8ecbb2762cefa88346.png)

I also tried a thing I saw on the Godot forum.

```auto
# For other scripts to access:
var nakama_client: NakamaClient :
	get:
		return nakama_client 
set(mod_value):
		nakama_client = _set_NC(mod_value) 

func _set_NC(value: NakamaClient) -> NakamaClient
         return value

```

But the error persist

---

<div class="post-metadata">

**Author:** ![sergisnt](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sergisnt/32/1377_2.png) [@sergisnt](https://forum.heroiclabs.com/u/sergisnt)\
**Post date:** [October 21, 2022, 6:44pm UTC](https://forum.heroiclabs.com/t/invalid-call-nonexistent-function-authenticate-email-async-in-base-nil-but-exists/3187/5 "2022-10-21T18:44:51Z")

</div>

I realized this. All those variables are null.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/heroiclabs/original/2X/8/8846dcb8ac9c8853fef105f026c480c3fd0f841e.png)

---

<div class="post-metadata">

**Author:** ![sergisnt](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sergisnt/32/1377_2.png) [@sergisnt](https://forum.heroiclabs.com/u/sergisnt)\
**Post date:** [October 22, 2022, 11:22am UTC](https://forum.heroiclabs.com/t/invalid-call-nonexistent-function-authenticate-email-async-in-base-nil-but-exists/3187/6 "2022-10-22T11:22:39Z")

</div>

(SOLUTION) I have found a solution (Although I don’t know if it is the correct way, but it works) The problem is that the client was getting null all the time. And I had to load this get\_nakama\_client function like this and add it to the return.

```auto
func get_nakama_client() -> NakamaClient:
	var NC: NakamaClient
	
	if NC == null:
		NC = Nakama.create_client(
			nakama_server_key,
			nakama_host,
			nakama_port,
			nakama_scheme,
			Nakama.DEFAULT_TIMEOUT,
			NakamaLogger.LOG_LEVEL.ERROR)
	
	return NC

```

![image](https://us1.discourse-cdn.com/flex020/uploads/heroiclabs/original/2X/4/48954b5843ea19cb08569314a4733d48ba9bf511.png)

I don’t know if I should apply any changes to the set, but for now everything works fine.

---

<div class="post-metadata">

**Author:** ![tom](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/tom/32/676_2.png) [@tom](https://forum.heroiclabs.com/u/tom)\
**Post date:** [October 24, 2022, 8:21am UTC](https://forum.heroiclabs.com/t/invalid-call-nonexistent-function-authenticate-email-async-in-base-nil-but-exists/3187/7 "2022-10-24T08:21:48Z")

</div>

Hi @sergisnt,

I’m glad you got it working. I would point out though that this does not appear to be a Nakama issue and is instead an issue with the Godot code in your project.

For example, the getter you have implemented will always create a new Nakama client (e.g. `NC` will never not be `null` during the `if` statement because you have only just defined it at the top of the `get_nakama_client` function so the `Nakama.create_client` will always happen); this in turn means your setter `nakama_client = mod_value` isn’t really doing anything useful because the underlying value of `nakama_client` is never used.

For a good example of implementing Nakama in Godot I would advise looking at our [Fish Game](https://github.com/heroiclabs/fishgame-godot) example project.
