local AgeNum = string.sub(Crop.Name,4,-1)--This results in results like "1", "2", "3", etc.
local i = tonumber(AgeNum)+1
script.Parent.Crop:FindFirstChild("Age"..i-1):Destroy()
tonumber() is not turning AgeNum into a number which is why i-1 is throwing the error message. how do I fix this?
I think the issue is that the code is interpreting "Age"..i-1 as ("Age"..i)-1. ("Age"..i) is a concatenation between a string and a number which is expected to give us a string, and the entire thing evaluates as a string minus 1, which makes no sense and thus the error occurs. Instead you need to prioritize the (i-1) calculation and then concatinate the result of that to the string "Age":