Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How come this script wont work?

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)

5 comments

0

error line 04 attempting to index a nil value

0

Because you set potatoes as nil on line 1... Should be a table value.

0

oh

0

wtfffff i come back to this

0

this basically visualizes indexing a nil value...

1 answer

✓ Accepted answer

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)


1 comment

1

hash slinging slasher slashes

This discussion is preserved as it was. New answers, comments, and votes are closed.