I am assuming that you are calling your script using AJAX. There is a lot that needs to be loaded for WP and ACF to work when using AJAX. If you want to do this then I would suggest searching for “wordpress ajax without admin-ajax.php”
The most useful documentation on using the correct way to do AJAX with WP is here.