Can I just check the facts are as I understand them so we are testing like for like
1) Your code is in a normal foreground app, not a service
2) Your app is open when you run the code
3) You are running your app in DroidScript, not a built APK
4) Settings > Apps > DroidScript > Permissions > Location
is set to whichever of the following two is available
Allow
Allow only while using the app
Can you tell us
a) the make and model of the device your code is running on
b) the version of Android
c) the version of DroidScript
d) details of your access point