Make a table only readonly

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

a module to make simply metatables

  1. What is the issue? Include screenshots / videos if possible!

one of arguments is nochange but i no know how to make only readonly

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

yes

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

-- This is an example Lua code block

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

i found a function

table.freeze(table)

haha i’m so dumb

1 Like
local metatable = {}
metatable.__newindex = function()
	return nil
end

local tables = {}

setmetatable(tables, metatable)

tables.key = 123

print(tables.key)
--nil is output

table.freeze() is native to Luau, you can achieve read-only tables in native Lua with the above.

2 Likes