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

Can a module() be use for A Settings Table?

I want people to configure the load asset to customize the looks from the model. But the script does not read the other content table from the "Settings Script"

The first script is named "Settings" And is a Module script.

local settings = {}

--Lightings Configurations

settings.SunFlare = true --Additional Custom Sunrays to the sun (Not Roblox Default Sunrays)

return settings

And i have another script name "MainSettings_Operation" Is another module() script.

local settings = settings(getmetatable)


if settings.SunFlare == true then
	script.Parent.Lensflare1:Clone().Parent = game.StarterGui
end

SunFlare is set to "True" And i want the script to Clone the "Lensflare1" For the sun effects

However, the script does not give the gui and i Might have use a wrong code? Or I have a mistake in this system?

6 comments

1

i believe to access a module script you need to require it

0

i dont know much about module scripts though, someone correct me if im wrong

1

You do realise the settings() function returns the studio settings right

1

The ones you can get with pressing ALT + S or FILE > Settings, and what is getmetatable doing here

0

What can i do for the script to access the other script settings to enable the SunFlare?

0

I see multiple people here answering your question and even 2 official answers telling you what to do, and you simply are not listening.

2 answers

✓ Accepted answer

Module scripts are ascertained via the require() method. So, you would do require(PATH_TO_YOUR_SETTINGS_MODULE), then do settings.SunFlare == true if statement.

1 comment

0

I have the Require() Already but the script need to access the Settings to enable the sunflare

As long as you put the module name before the variable you should be able to access the settings. This is a very simple example:

Module

local setting = {} -- you could also put settings in the {} like a table
	
setting.SettingHere = "Hello"

return setting

Script

local setting= require(game.ReplicatedStorage.ModuleScript)

print(setting.SettingHere) -- prints Hello

This also works in LocalScripts

4 comments

0

I have 1 module setting that for configuration, And the other Module Script is for checking the value of the setting that if true/false is set https://gyazo.com/46b314345539f03b949f4d802cb70c0e

0

Dude, just use a Configuration Folder. use that to check if something is true or false, and you don't have to bother using a "module()" to do it.

0

This is honestly exactly what he was asking for and also in a clean and easy to understand format. So him not accepting this is just because he didn't even attempt to try your solution.

0

I did try the solution it almost work but the local setting= require(game.ReplicatedStorage.ModuleScript) Did not go.

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