Actually, you should know that 50p isn't anymore developing Script Editor.
And your codes are wrong.
Errors:
1. The function MUST NOT be named when it only is attached to a specific event handler.
2. If the function may be used by more than just an event handler then you should name it and place it before the event handler, without being inside the addEventHandler function, like this:
function a ()
--Code...
end
addEventHandler ("onResourceStart", getResourceRootElement(), a)