Random Library
Install Source Code how to use
hello everyone! Today, me and my friend @Biack1st present to our our Random Library module! Using this module you can easily create random chances and get random points in objects!
-- random chance object
local Module = require(game.ReplicatedStorage.RandomLibary)
local myTable = {
["Cool Item"] = {
["Item"] = "COOL",
["Chance"] = 10
},
["Not Cool Item"] = {
["Item"] = "Epic",
["Chance"] = 200 --- each mini-table inside a loot table MUST have a index called "chance".
}
}
print(Module:GetRandomChance(myTable)) -- prints the item the library returned
-- gets a random point inside a part
local Library = require(game.ReplicatedStorage.RandomLibary)
local Part = script.Parent
local RandomPoint = Library:GetRandomPointInPart(Part) -- gets a random point inside the part(cframe)
local NewPart = Instance.new("Part")
NewPart.Anchored = true
NewPart.CFrame = RandomPoint
NewPart.Parent = workspace
-- gets a random point inside a Model
local Library = require(game.ReplicatedStorage.RandomLibary)
local Model = script.Parent
local RandomPoint = Library:GetRandomPointInModel(Model) -- gets a random point inside the model(cframe)
local NewPart = Instance.new("Part")
NewPart.Anchored = true
NewPart.CFrame = RandomPoint
NewPart.Parent = workspace
-- Random point in Region
local Module = require(game.ReplicatedStorage.RandomLibary)
local Region = Region3.new(Vector3.new(100,100,100), Vector3.new(0,0,0))
local RandomPoint = Module:GetRandomPointInRegion(Region.Size, Region.CFrame) -- gets a random point inside the region(cframe)
local Part = Instance.new("Part")
Part.CFrame = RandomPoint
Part.Anchored = true
Part.Parent = workspace
Examples
BUBBLES!!!
This was done using the :GetRandomPointInPart function
Random Chance system!!
You may notice how the “death” option comes more. While the happiness comes less and the epicness comes slightly more than the happiness
Credit
- HUGE credit to my friend @Biack1st, he wrote the :GetRandomPoint functoins and the github pages!
Outro
I hope this could help you out! If you come across any issues, bugs, have questions, feedback or suggestions then feel free to say them here! byeee