Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR LUA

roblox difference between index and newindex

myMetaTable = {
	__index = function(table, index)
		print("Sorry, but the element ".. tostring(index).. " does not exist.")
		-- runs when you try to index a nil element of the table this metatable is connected to, table[index]
	end,
	__newindex = function(table, index, value)
		print("Sorry, but the element ".. tostring(index).. " can't be set to ".. tostring(value).. " because this element does not exist.")
		-- runs when you try to index and set a nil element of the table this metatable is connected to, table[index] = value
	end
}
 
PREVIOUS NEXT
Tagged: #roblox #difference #index #newindex
ADD COMMENT
Topic
Name
9+4 =