How come this script doesnt work?
potatoes = nil function mash_potatoes(softness) for i, v in pairs(potatoes) do if v.Softness < softness then v.Mashedness.Value = v.Mashedness.Value-1 end end end mash_potatoes(1)
Ok, it seems that you want to iterate through a table called potatoes but you indexed potatoes as a nil value. potatoes should refer to a table with another table inside it containing two properties called Softness and Mashedness. From the looks of it, Mashedness should be a NumberValue. You should also change the context of potatoes to local instead of having it global.
local potatoes = { potato ={ Softness = 0, Mashedness = Instance.new("NumberValue",game:GetService'Workspace') } } function mash_potatoes(softness) for i, v in pairs(potatoes) do if v.Softness < softness then v.Mashedness.Value = v.Mashedness.Value-1 end end end mash_potatoes(1)