# How to acces gui script? (SOLVED)

**URL:** <https://forum.defold.com/t/how-to-acces-gui-script-solved/1902>\
**Category:** Questions\
**Created:** [May 22, 2016, 10:23am UTC](https://forum.defold.com/t/how-to-acces-gui-script-solved/1902 "2016-05-22T10:23:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexander\_Osadchenko](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/alexander_osadchenko/32/1433_2.png) [@Alexander\_Osadchenko](https://forum.defold.com/u/Alexander_Osadchenko)\
**Post date:** [May 22, 2016, 10:23am UTC](https://forum.defold.com/t/how-to-acces-gui-script-solved/1902/1 "2016-05-22T10:23:31Z")

</div>

How i can acces gui script. Please give me exemples not references to tutorials.

---

<div class="post-metadata">

**Author:** ![sicher](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sicher/32/8_2.png) [@sicher](https://forum.defold.com/u/sicher)\
**Post date:** [May 22, 2016, 11:55am UTC](https://forum.defold.com/t/how-to-acces-gui-script-solved/1902/2 "2016-05-22T11:55:05Z")

</div>

If you have a GUI component “my\_gui” in game object “my\_object” and the GUI component has a GUI script added, you can access it from any other script or gui script with messages:

```lua
msg.post("my_object#my_gui", "hello_gui")

```

In the GUI script:

```lua
function on_message(self, message_id, message, sender)
    if message_id == hash("hello_gui") then
        msg.post(sender, "hello_back")
    end
end

```

---

<div class="post-metadata">

**Author:** ![Alexander\_Osadchenko](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/alexander_osadchenko/32/1433_2.png) [@Alexander\_Osadchenko](https://forum.defold.com/u/Alexander_Osadchenko)\
**Post date:** [May 22, 2016, 1:39pm UTC](https://forum.defold.com/t/how-to-acces-gui-script-solved/1902/3 "2016-05-22T13:39:48Z")

</div>

![](https://forum-defold-uploads.b-cdn.net/original/2X/a/ada5968e686dc1be2d2036a12afb938cf9a7c0e8.png)

---

<div class="post-metadata">

**Author:** ![Alexander\_Osadchenko](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/alexander_osadchenko/32/1433_2.png) [@Alexander\_Osadchenko](https://forum.defold.com/u/Alexander_Osadchenko)\
**Post date:** [May 22, 2016, 1:40pm UTC](https://forum.defold.com/t/how-to-acces-gui-script-solved/1902/4 "2016-05-22T13:40:16Z")

</div>

![](https://forum-defold-uploads.b-cdn.net/original/2X/b/ba8d7ed95aabea27d975ed0e97e29ad625f08973.png)

My script cant acces gui button

---

<div class="post-metadata">

**Author:** ![sicher](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sicher/32/8_2.png) [@sicher](https://forum.defold.com/u/sicher)\
**Post date:** [May 22, 2016, 1:41pm UTC](https://forum.defold.com/t/how-to-acces-gui-script-solved/1902/5 "2016-05-22T13:41:11Z")

</div>

Edit: It seems like you have misunderstood message passing and perhaps mixed them up with API function calls. You should take the time and study how message passing works in Defold. [Message passing in Defold](http://www.defold.com/manuals/message-passing/)

---

<div class="post-metadata">

**Author:** ![Alexander\_Osadchenko](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/alexander_osadchenko/32/1433_2.png) [@Alexander\_Osadchenko](https://forum.defold.com/u/Alexander_Osadchenko)\
**Post date:** [May 22, 2016, 1:42pm UTC](https://forum.defold.com/t/how-to-acces-gui-script-solved/1902/6 "2016-05-22T13:42:09Z")

</div>

Did you mean proxy colection or simply level colection?

 ![](https://forum-defold-uploads.b-cdn.net/original/2X/e/e0b9b9d97cb0a4fb823941ba959664f5628c27ae.png)

---

<div class="post-metadata">

**Author:** ![sicher](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sicher/32/8_2.png) [@sicher](https://forum.defold.com/u/sicher)\
**Post date:** [May 22, 2016, 1:45pm UTC](https://forum.defold.com/t/how-to-acces-gui-script-solved/1902/7 "2016-05-22T13:45:05Z")

</div>

Since you send messages to socket “level” with the URL “level:CompGui#…” you need to understand what a socket is. They are a way to address different “systems” or “worlds” in the engine. For instance for the main collection read at startup and for collections loaded through a proxy.

---

<div class="post-metadata">

**Author:** ![Alexander\_Osadchenko](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/alexander_osadchenko/32/1433_2.png) [@Alexander\_Osadchenko](https://forum.defold.com/u/Alexander_Osadchenko)\
**Post date:** [June 12, 2016, 2:05pm UTC](https://forum.defold.com/t/how-to-acces-gui-script-solved/1902/8 "2016-06-12T14:05:12Z")

</div>

yhank you for your help now all going well
