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

Preventing C Stack Overflows with __index?

Hello! I am having an issue where I am overriding the table's __index method, but whenever I index the table, I get a C Stack Overflow. Why is this?

local Table = {}
local Metatable = {}

Metatable.__index = function(Key,Value)
	if Value > 10 then
		Table[Key] = 10
	else
		Table[Key] = Value
	end
end

1 answer

✓ Accepted answer

should be using .__newindex instead of __index

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