This function returns the script index of the script assigned to run at the end of rendering the given layer, or it will return -1 if no script is assigned. You supply the layer ID (which you get when you create the layer using layer_create()) or the layer name (as a string - this will have a performance impact).
Argument Description layer_id The unique ID value of the layer to target (or the layer name as a string)
Script Index (Real) or -1 if no script is assigned
if layer_get_script_end(layer) == -1
The above code will check to see if the layer that the instance running the code has a script assigned to it and if it doesn't one is assigned.