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)
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)
hash slinging slasher slashes
This discussion is preserved as it was. New answers, comments, and votes are closed.
5 comments
error line 04 attempting to index a nil value
Because you set potatoes as nil on line 1... Should be a table value.
oh
wtfffff i come back to this
this basically visualizes indexing a nil value...