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

How can I use settings in a Module Script?

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)

2 comments

0

be more specific, what settings are you talking about?

0

Do you mean a "Configurations" object containing Value objects? Can you be more specific?

1 answer

✓ Accepted answer

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
})

1 comment

0

Thanks! :D

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