# How to communicate two different script verse files to each other.

**URL:** <https://forums.unrealengine.com/t/how-to-communicate-two-different-script-verse-files-to-each-other/748993>\
**Category:** Programming & Scripting\
**Tags:** unreal-editor-for-fortnite, fortnite\
**Created:** [January 14, 2023, 3:46am UTC](https://forums.unrealengine.com/t/how-to-communicate-two-different-script-verse-files-to-each-other/748993 "2023-01-14T03:46:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DolphinDom](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dolphindom/32/637016_2.png) [@DolphinDom](https://forums.unrealengine.com/u/DolphinDom)\
**Post date:** [January 14, 2023, 3:47am UTC](https://forums.unrealengine.com/t/how-to-communicate-two-different-script-verse-files-to-each-other/748993/1 "2023-01-14T03:47:00Z")

</div>

I want to be able to call a function in a separate script or have a variable shared between two different scripts, but I cannot figure out how to get the two different scripts to be aware the other exists. Are there any examples of how to do this anywhere?

---

<div class="post-metadata">

**Author:** ![sonictke](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sonictke/32/924209_2.png) [@sonictke](https://forums.unrealengine.com/u/sonictke)\
**Post date:** [January 14, 2023, 8:40am UTC](https://forums.unrealengine.com/t/how-to-communicate-two-different-script-verse-files-to-each-other/748993/2 "2023-01-14T08:40:56Z")

</div>

Hi @DolphimDom:

The team has got a bit of work to do on documenting how Verse scoping works, but to answer your question directly, if you had the following Verse scripts within your project:

In `hello_world_device.verse`:

```auto
Foo():void=
    return

```

And another function in `hello_world_device2.verse`:

```auto
Bar():void=
    Foo()

```

This should already be compilable. If you hover over the `Foo` symbol in VS Code, the LSP should also show you the full Verse path of that function symbol:

```auto
(/localhost/_MyProjectC:)Foo():void

```

Behind the scenes, the `Foo` and `Bar` symbols are defined under your project’s Verse path, which helps avoid namespace collisions. You can wrap these functions into modules/classes to help encapsulate them further:

```auto
my_module := module:
    Foo<public>():void=
        return

```

In your other script file, you’d then need to first import your new module:

```auto
using { my_module }

```

And then you can again use the function as-is in `Bar`:

```auto
Bar():void=
    Foo()

```

This isn’t the only way to do things in Verse and is far from the full set of rules surrounding scoping, but hopefully that gives you a clearer idea of where to start. Please feel free to provide feedback on the documentation located at: [https://www.epicgames.com/fortnite/en-US/creative/docs/uefn/Verse/modules-and-paths-in-verse](https://www.epicgames.com/fortnite/en-US/creative/docs/uefn/Verse/modules-and-paths-in-verse) regarding this subject.

---

<div class="post-metadata">

**Author:** ![LuckofBuck](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/luckofbuck/32/677363_2.png) [@LuckofBuck](https://forums.unrealengine.com/u/LuckofBuck)\
**Post date:** [April 17, 2023, 5:32am UTC](https://forums.unrealengine.com/t/how-to-communicate-two-different-script-verse-files-to-each-other/748993/3 "2023-04-17T05:32:36Z")

</div>

If I have 2 scripts but want to use := class(creative\_device): is there a way to associate one with the other? My main desire is to use @editable in both which needs to be a class with a creative\_device.

game\_manager.verse

```auto
game_manager:= class(creative_device):

    OnBegin<override>()<suspends>:void=
       Foo()

```

hello\_world\_device.verse

```auto
hello_world_device := class(creative_device):
    Foo():void=
        Print("Hi")

```

---

<div class="post-metadata">

**Author:** ![LuckofBuck](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/luckofbuck/32/677363_2.png) [@LuckofBuck](https://forums.unrealengine.com/u/LuckofBuck)\
**Post date:** [April 17, 2023, 5:47am UTC](https://forums.unrealengine.com/t/how-to-communicate-two-different-script-verse-files-to-each-other/748993/4 "2023-04-17T05:47:26Z")

</div>

Ended up figuring out from another forum post: [How do I call a method on another verse device?](https://forums.unrealengine.com/t/how-do-i-call-a-method-on-another-verse-device/833185)

Basically for my example @editable then reference the other script, and then it can be called.

```auto
game_manager:= class(creative_device):
    @editable
    hello_world_device_ref: hello_world_device= hello_world_device{}
    

    OnBegin<override>()<suspends>:void=
       hello_world_device_ref.Foo()

```

---

<div class="post-metadata">

**Author:** ![MattRix](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mattrix/32/686548_2.png) [@MattRix](https://forums.unrealengine.com/u/MattRix)\
**Post date:** [April 24, 2023, 3:24pm UTC](https://forums.unrealengine.com/t/how-to-communicate-two-different-script-verse-files-to-each-other/748993/5 "2023-04-24T15:24:27Z")

</div>

Another solution to this problem would be using a global singleton reference to the device, I have an example of that here: [I came up with a way to make singletons in Verse](https://forums.unrealengine.com/t/i-came-up-with-a-way-to-make-singletons-in-verse/1139453)
