Hey everyone, I have a script that runs a randomizer, that finds the ‘rarity’, and the ‘item’ from 3 different tables (uncommon, common, and their ‘items’.
I’m wondering how I could take these variables (itemRarity, chosenItem), and ‘convert’ them into an object in the game through ReplicatedStorage. I have folder(s) in RepStorage of the Common & Uncommon ‘tables’ of items, but I don’t know how to communicate that into the script to actually create/clone the modles I’m looking for. If anyone has any ideas please let me know!
Images – The script
local rarities = {
"Common",
"Uncommon",
}
local itemCommon = {
"Tin Can",
"Plastic Bag",
"Water Bottle"
}
local itemUncommon = {
"Glass Bottle",
}
local itemRarity = ""
local chosenItem = ""
local function newItem()
local commonR = "Common"
local uncommonR = "Uncommon"
local rarityChance = 0
rarityChance = math.random(1,100)
print(rarityChance)
if rarityChance < 75 then
itemRarity = "Common"
chosenItem = math.random(1, #itemCommon)
else
itemRarity = "Uncommon"
chosenItem = math.random(1, #itemUncommon)
end
end
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SandyS = ReplicatedStorage.SandyShallows:GetChildren("BoolValue")
local folder = ReplicatedStorage.SandyShallows
for _, v in ipairs(folder:GetChildren()) do --loop through the folder
if v.Value == false then
newItem()
print(v.Name, chosenItem, itemRarity)
v.Value = true
end
print(v.Name, v.Value)
end