generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: ModuleScripts

Previous Thread :: Next Thread 
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
21 Oct 2015 03:29 PM
Whenever I change variables in a module, and require it with another script, that script will see and use the changes and not its original source. Is there a way to avoid this?
Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
21 Oct 2015 03:32 PM
Or is this that case where I should use linkedsource XD
Report Abuse
UFAIL2 is online. UFAIL2
Joined: 14 Aug 2010
Total Posts: 6905
21 Oct 2015 03:37 PM
That's the point of module scripts. If you want to return the exact code that was written do something like this:

--ModuleScript
local module = {}

local actual_module = {}

function module:Get()
return actual_module
end

--LocalScript
local module = require(MODULE_PATH):Get()

Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
21 Oct 2015 03:37 PM
Store all your private variables for the module in a table, and your public ones in a separate table. Then simply use each accordingly.
Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
21 Oct 2015 03:41 PM
Sorry but I have no clue ;l

What I want to do is have the whole system (with events and variables) stored in a module and have a normal script require the module. But when I first use it on one thing, then on a different thing it uses the settings from the latest use
Report Abuse
UFAIL2 is online. UFAIL2
Joined: 14 Aug 2010
Total Posts: 6905
21 Oct 2015 03:43 PM
So if you want every script to have it's own table read my other post.
Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
21 Oct 2015 03:52 PM
But the variables aren't in a table, actually everything in the real table in the module is a function that creates all event connections to the system user, the functions those connections fire are in the modulescript but not in a table.
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
21 Oct 2015 03:53 PM
UFAIL2:
you forgot to make the module return something :3


Red Blossoms
Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
21 Oct 2015 04:09 PM
bump
Report Abuse
IllegallyBlind is not online. IllegallyBlind
Joined: 07 Nov 2010
Total Posts: 1691
21 Oct 2015 04:16 PM
ufail2 failed at his module script :(


i make u math.sqrt()
Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
21 Oct 2015 04:17 PM
But that's not the point
Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
21 Oct 2015 04:25 PM
help
Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
21 Oct 2015 05:30 PM
UFAIL, your way doesn't seem to work ;l

I currently have a module for the private variables, require that and require with that table the system's module, but still whenever I adjust the table a new system user will see these adjustments as well..
Report Abuse
HRnSN is not online. HRnSN
Joined: 22 Jun 2009
Total Posts: 1276
21 Oct 2015 05:40 PM
Show us the code within the module script?
Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
21 Oct 2015 05:42 PM
local module = {}

local ActualModule = {
-- Table with vars
}

function module:Get()
return ActualModule
end

return module
Report Abuse
HRnSN is not online. HRnSN
Joined: 22 Jun 2009
Total Posts: 1276
21 Oct 2015 05:45 PM
local Module = {}

function Module:Get()

local ActualModule = {

--Values or whatever

}

return ActualModule

end

return Module
Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
21 Oct 2015 06:00 PM
Oooh, that's just it!

Thank you so much I feel stupid now, you saved my day ;3
Report Abuse
HRnSN is not online. HRnSN
Joined: 22 Jun 2009
Total Posts: 1276
21 Oct 2015 06:12 PM
Anytime :p
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image