# Lua Script not working cause of not planted plant

**URL:** <https://forum.farmbot.org/t/lua-script-not-working-cause-of-not-planted-plant/9113>\
**Category:** Troubleshooting\
**Created:** [May 18, 2024, 1:41pm UTC](https://forum.farmbot.org/t/lua-script-not-working-cause-of-not-planted-plant/9113 "2024-05-18T13:41:04Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Christian](https://forum.farmbot.org/user_avatar/forum.farmbot.org/christian/32/5172_2.png) [@Christian](https://forum.farmbot.org/u/Christian)\
**Post date:** [May 19, 2024, 8:05pm UTC](https://forum.farmbot.org/t/lua-script-not-working-cause-of-not-planted-plant/9113/4 "2024-05-19T20:05:46Z")

</div>

Hi @jsimmonds

My Farmbot is running the latest version. I took the code from this forum entry [Nested sequences and Plant Groups - #13 by roryaronson](https://forum.farmbot.org/t/nested-sequences-and-plant-groups/7247/13)

The “plant” feature is described in more detail in this documentation

> **[April 11, 2023 Software and Documentation Update](https://farm.bot/blogs/news/april-11-2023-software-and-documentation-update)**
>
> Hello all,
> Today we released a new version of FarmBot OS, the web app, several of our featured sequences, and published updates to our developer documentation. Here’s what’s new:
> 
> water(plant) Lua helper
> We’ve added a new...

I have also already executed this shared sequence [The FarmBot Web App](https://my.farm.bot/app/shared/sequence/158) which should update all plants.

Unfortunately no success. It still returns the error that the plant has not yet been planted.

I have now rebuilt the LUA script and use “dispense” instead of “water(plant)”.

However, my aim is for the Farmbot to create a soil moisture reading for each group of plants and use this as a basis for deciding whether or not to water a group.

I have extended the script from the forum to measure three plant groups. This works well so far but …

It only waters the first plant in the group and then jumps to the next group. It seems as if the loop from the script is not working properly.

 ![image](https://forum.farmbot.org/uploads/default/original/2X/e/e44c4153a89283f3d736b1bca05dbbf3f583cb1e.png)

> if soil\_moisture\_1 \< moisture\_threshold\_all then  
> for i, member in ipairs(group(variable(“Group ID #1”))) do  
> plant = api({  
> method = “get”,  
> url = “/api/points/” … member  
> })  
> move\_absolute(plant.x, plant.y, 0)  
> dispense1 = variable(“Dispense #1”)  
> dispense(dispense1)  
> end  
> end

@roryaronson You had provided the LUA code in the forum. Perhaps you have an idea what I am doing wrong here?

Thank you in advance for your support

Greetings Christian

---

_[View the full topic](https://forum.farmbot.org/t/lua-script-not-working-cause-of-not-planted-plant/9113)._
