Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Preventing C Stack Overflows with __index?

Asked by
marfit 104
3 years ago
Edited 3 years ago

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

Log in to vote
0
Answered by 3 years ago

should be using .__newindex instead of __index

Ad

Answer this question