My controller was not getting used even after calling setController.
Changing this
// Load fxml file
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setController(new GUIController(script, this));
final Parent root = fxmlLoader.load(getClass().getResource("sample.fxml"));
to this
// Load...