# GUI Button - what am I missing? (SOLVED)

**URL:** <https://forum.defold.com/t/gui-button-what-am-i-missing-solved/46321>\
**Category:** Questions\
**Created:** [March 14, 2019, 4:43pm UTC](https://forum.defold.com/t/gui-button-what-am-i-missing-solved/46321 "2019-03-14T16:43:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kleber.swf](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/kleber.swf/32/9106_2.png) [@kleber.swf](https://forum.defold.com/u/kleber.swf)\
**Post date:** [March 14, 2019, 4:43pm UTC](https://forum.defold.com/t/gui-button-what-am-i-missing-solved/46321/1 "2019-03-14T16:43:01Z")

</div>

Hi there,

I’m new to Defold Engine, so this might be a REEEEAALLY noob question.

I created a button with a simple GUI Script and attached to it.

```
function init(self)
    print('button initialized')
end

```

Added this button.gui to a main.gui as a template.  
Added the main.gui to the main.collection.  
But the print never happens! What I am doing wrong here?

To test if it was working, I put the button.gui directly inside main.collection and it worked. So the issue must be with the main.gui.

---

<div class="post-metadata">

**Author:** ![Jerakin](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/jerakin/32/3997_2.png) [@Jerakin](https://forum.defold.com/u/Jerakin)\
**Post date:** [March 14, 2019, 4:51pm UTC](https://forum.defold.com/t/gui-button-what-am-i-missing-solved/46321/2 "2019-03-14T16:51:55Z")

</div>

Hi and welcome!

Unfortunately templates doesn’t use/run the attached script at all. You will need to add your interaction with the button to the gui scene that is using the gui template (in your case main.gui).

---

<div class="post-metadata">

**Author:** ![kleber.swf](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/kleber.swf/32/9106_2.png) [@kleber.swf](https://forum.defold.com/u/kleber.swf)\
**Post date:** [March 14, 2019, 5:00pm UTC](https://forum.defold.com/t/gui-button-what-am-i-missing-solved/46321/3 "2019-03-14T17:00:23Z")

</div>

OK! Thanks

---

<div class="post-metadata">

**Author:** ![Axel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/axel/32/11723_2.png) [@Axel](https://forum.defold.com/u/Axel)\
**Post date:** [March 15, 2019, 8:45am UTC](https://forum.defold.com/t/gui-button-what-am-i-missing-solved/46321/4 "2019-03-15T08:45:31Z")

</div>

[Here’s](https://www.defold.com/examples/gui/button/) a hands-on example of a button as well. [This asset](https://www.defold.com/community/projects/101219/) might also be of interest.

Good luck!
