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 » Scripting Helpers
Home Search
 

I'm trying to Utilize ModuleScripts

Previous Thread :: Next Thread 
CitreIthkarr is not online. CitreIthkarr
Joined: 09 Jan 2014
Total Posts: 454
10 Mar 2014 07:00 PM
So I'm planning to have hundreds of blocks all with scripts that reference one module script, but in blog it says

"ModuleScripts will run at most one time — if two scripts require() the same ModuleScript Instance, that script will run once, and produce the same exact return value to both require()ers"

So does that mean that if I have 100 scripts all calling the same module script function at the same time, but with different variables, it will return 100 of the same numbers instead of them each being unique?
Report Abuse
CitreIthkarr is not online. CitreIthkarr
Joined: 09 Jan 2014
Total Posts: 454
10 Mar 2014 07:42 PM
On a related note

19:41:08.447 - Requested module experienced an error while loading
19:41:08.448 - Script 'Workspace.Dirt.Script', Line 2
19:41:08.448 - stack end

local Dirt = script.Parent
local GrowingModule = require(Workspace.GrowingModule)

Game.Workspace.GrowTick.Changed:connect(function()
print(GrowingModule.Grow(Dirt.Water,Dirt.Nutrients))
end)
Report Abuse
CitreIthkarr is not online. CitreIthkarr
Joined: 09 Jan 2014
Total Posts: 454
10 Mar 2014 08:53 PM
20:52:16.893 - Module code did not return exactly one value

???
Report Abuse
DataStore is not online. DataStore
Joined: 07 Feb 2012
Total Posts: 8540
10 Mar 2014 09:26 PM
@Cith,
What's the ModuleScript returning?
Report Abuse
CitreIthkarr is not online. CitreIthkarr
Joined: 09 Jan 2014
Total Posts: 454
10 Mar 2014 09:29 PM
I fixed a bit of the issue by adding

return module

at the end, this is how I have it:
--

local Plant = {}

function Plant.Grow(Wlvl,Nlvl)
local GrowChance = math.random(1,20/Wlvl)
local GrowModify = GrowChance - Nlvl
if GrowModify < 2 then
return true
end
end

return module

--
And I'm accessing it through this:
--

local Dirt = script.Parent
local GrowingModule = require(Workspace.GrowingModule)

Game.Workspace.GrowTick.Changed:connect(function()
print(GrowingModule.Grow(Dirt.Water,Dirt.Nutrients))
end)


--
And now I'm Getting
21:28:12.001 - Workspace.Dirt.Script:5: attempt to index upvalue 'GrowingModule' (a nil value)
21:28:12.001 - Script 'Workspace.Dirt.Script', Line 5
21:28:12.002 - stack end
Report Abuse
DataStore is not online. DataStore
Joined: 07 Feb 2012
Total Posts: 8540
10 Mar 2014 09:36 PM
'module' is nil.

return Plant

Report Abuse
CitreIthkarr is not online. CitreIthkarr
Joined: 09 Jan 2014
Total Posts: 454
10 Mar 2014 09:47 PM
Oi it works great now! Thanks a ton
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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