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

How do I turn this module script I made into a random rarity / weight choosing system?

Asked by 5 years ago
Edited 5 years ago

Hi there! I am making a game with an egg hatching system, but I don't know how to turn this module script I made into a random rarity / weight choosing system. Can someone explain how to do this, and / or insert a script and explain the piece of script to me so I know what to script into my script and / or change it it fit your script? The script is a module script in the replicated storage.

Thanks For Your Time!

01local module = {
02    ["Tier1"] = {
03        ["Cost"] = 25,
04        ["Currency"] = "Coins"
05        ["Pets"] = {-- {Rarity,Damage,Health}
06            ["Duck"] = {40,1,15},
07            ["Blue Duck"] = {20,2,40},
08            ["Red Duck"] = {20,4,20},
09            ["Purple Duck"] = {10,4,35},
10            ["Green Duck"] = {10,3,50}
11        }
12    }
13 
14}
15 
16return module
0
LOL THAT IS UNBALANCED Elixcore 1337 — 5y
0
No its not :> NarwhalAndMe 141 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

You don't seem to know how modules work.

Modules are like classes, for example:

1local module = {}
2 
3return module

Now you can add all sorts of stuff to that module, which you then return:

1local module = {}
2 
3function module.helloWorld()
4    print("Hello, world!")
5end
6 
7return module

Now, you would do something like this:

1local m = require(game.Workspace.ModuleScript)
2m.helloWorld()

By the way, modules act like normal scripts. They, in fact, are. They just need to be executed (using the require() function):

1local module = {}
2 
3function something()
4    print(1+1)
5end
6 
7something()
8 
9return module

^ This, alone, won't do anything. But, if you invoke it from another script like:

1require(game.Workspace.ModuleScript)

It will output 2 to the console.

Your question's answer: ... is contained in this question. Go read it, it's almost the same as yours. The first answer is written awesomely.

0
Thanks! I will look at the other question! NarwhalAndMe 141 — 5y
Ad

Answer this question