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

Accessing tables inside a ModuleScript?

I am currently working on an admin script but I am having some issues with the settings area mainly because I have never worked with ModuleScripts before but I feel like it is the best route to take. So my question is, how would I access the contents like admins etc. in this module script from another script? I am making a function that checks to see if the player is an admin (found below the module script) and I don't know how I would check the admin table inside the ranks dictionary.

Any advice would be great (wiki links, etc.). Thanks!

ModuleScript

--[[
These are the settings for Bman's Admin, if you have any questions or issues please contact
me (Bman8765) by sending me a message and I'll try to help!
--]]

return {
	----------------[[ ADMINS ]]-----------------
	Ranks = {
		["Admin"] = {"Bman8765"}; -- Can use everything
		["Banned"] = {"Noob", "Butt", "Idiot"}; -- Locked out of the server
	}
	---------------------------------------------

	----------------[[ SETTINGS ]]---------------

	---------------------------------------------
}

The Function for checking if an admin

function adminCheck(name)
	for _, Name in pairs (IDK HOW TO ACCESS THE TABLE HERE) do
		if (Name == name) then
			return true
		end
	end
	return false
end

1 comment

0

Yea mine runs off a module script, I feel your confusion..

1 answer

✓ Accepted answer

I'm guessing that your module script is returning a function (which is generally what you want to do to load your module). When you want to access your table, you put it as an argument for the function you're returning.

In your module script:

return function(tables)
	--do module script here
	return adminsettings -- Return the settings for our admin.
end

and in your main loader script

func = require(module) -- This will load our module script, into a function that we can run.
settings = func(table1, table2, table3) -- I'm not sure if this is the correct syntax, but you do something like this.

1 comment

0

Worked, thanks for the help

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