Just a side note (you probably already know this:
this can be the same as source, but it doesn't have to be.
For example here:
local myButton = createButton(0.5, 0.5, 0.1, 0.1, "Click me!", true)
addEventHandler("onClientGUIClick", resourceRoot, function()
outputChatBox("Button clicked!")
end)
this is always resourceRoot
While source in this set-up is always a GUI element of this resource.
For @Xwaw
See image below, is the element tree, where you can see some of the main parent elements in MTA.
root at the very top is the parent for ALL elements within your game:
This includes players,
resources(resourceRoot's) > maps/'scripted created elements' and everything that hangs directly under those.
resourceRoot is the main parent of each resource. Which can be used to listen to events created by elements that are part of a specific resource.
Info: https://wiki.multitheftauto.com/wiki/Element_tree