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

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

Asked by 6 years ago

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?

1
i believe to access a module script you need to require it DinozCreates 1070 — 6y
0
i dont know much about module scripts though, someone correct me if im wrong DinozCreates 1070 — 6y
1
You do realise the settings() function returns the studio settings right User#24403 69 — 6y
1
The ones you can get with pressing ALT + S or FILE > Settings, and what is getmetatable doing here User#24403 69 — 6y
View all comments (2 more)
0
What can i do for the script to access the other script settings to enable the SunFlare? S0NIC_Dev 61 — 6y
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. SteamG00B 1633 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

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.

0
I have the Require() Already but the script need to access the Settings to enable the sunflare S0NIC_Dev 61 — 6y
Ad
Log in to vote
1
Answered by
zblox164 531 Moderation Voter
6 years ago

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

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 S0NIC_Dev 61 — 6y
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. Formidable_Beast 197 — 6y
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. SteamG00B 1633 — 5y
0
I did try the solution it almost work but the local setting= require(game.ReplicatedStorage.ModuleScript) Did not go. S0NIC_Dev 61 — 5y

Answer this question