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

How can I use settings in a Module Script?

Asked by 5 years ago

Alright,

So I am making an Anti-Exploit Module and I want the User to be able to Set the settings through the loader script Eg...

require(03048303)

I have seen it on Admins before. I know it is possible. I just don't know how. And I couldn't find anything on the Roblox Wiki about it.

Thanks, Enomphia

(Response that helps will be upvoted :D)

0
be more specific, what settings are you talking about? radusavin366 617 — 5y
0
Do you mean a "Configurations" object containing Value objects? Can you be more specific? Link150 1355 — 5y

1 answer

Log in to vote
2
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
5 years ago

You could make your module return a function (or a metatable with __call to prevent using getfenv on it), which accepts a table with settings as an argument.

Example:

local Settings = {}

--module's code blabla

return function(t)
    --verify if the table is valid or something
    Settings = t
end

Or the one with __call:

local Settings = {}

--module's code blabla

return setmetatable({}, {__call = function(self, t)
    --verify if the table is valid or something
    Settings = t
end, __metatable = false})

And you would pass the settings like this:

require(03048303)({
    Something = true
})
0
Thanks! :D Enomphia 39 — 5y
Ad

Answer this question