so i am making a natural selection simulation where animals would eat food and fight to survive basically. I have it so that plants can make seeds and i made it so that some seeds would be edible and some wont. My issue is in the seeds that are edible. whenever the seed gets touched by an animal, it says ( Workspace.Seeds.SeedToDuplicate.SeedIsEaten:7: attempt to index nil with 'Value' ) this is the script that is geting the error.
--script is in the seed local seed = script.Parent seed.Touched:Connect(function(hit) if hit.Parent.Parent == workspace.Population and seed:FindFirstChild("Edible").Value == true then local nutrients = seed:FindFirstChild("Nutrients") local animal = hit.Parent local energy = animal:FindFirstChild("Energy") energy.Value = energy.Value + nutrients.Value --ERROR IS IN THIS LINE seed:Destroy() end end)
I have absolutely no idea why it would give that error and I dont know how I would fix it so any ideas would really help thanks
either energy or nutrients does not exist please check if they exist