You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want the ColorTable to get every value inside the table(the rarity that is picked) example: [255,255,255] -
What is the issue? Include screenshots / videos if possible!
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
found a bunch of posts but none of them worked.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local EggHatch = {}
local Eg = script.Parent
local Pets = game.ReplicatedStorage.Pets:WaitForChild(“BasicEgPets”)
local FireShowcase = game.ReplicatedStorage.Events:WaitForChild(“FireShowcase”)
EggHatch.Color = {-- colors for the copied egg
["Legendary"] = {242, 255, 0},
["Epic"] = {202, 22, 234},
["Rare"] = {39, 179, 255},
["UnCommon"] = {17, 255, 0},
["Common"] = {255,255,255}
}
EggHatch.Pet = { – eggs inside folder
["Legendary"] = {
Pets.Legendary:GetChildren()
},
["Epic"] = {
Pets.Epic:GetChildren()
},
["Rare"] = {
Pets.Epic:GetChildren()
},
["UnCommon"] = {
Pets.Uncommon:GetChildren()
},
["Common"] = {
Pets.Common:GetChildren()
}
}
EggHatch.rarities = {
["Legendary"] = 2,
["Epic"] = 5,
["Rare"] = 20,
["UnCommon"] = 35,
["Common"] = 65,
}
function EggHatch.Hatch(plr)
local RandomNum = math.random(1,100)
RandomNum += math.random(1,10) or 0
local counter = 0
for rarity, weight in pairs(EggHatch.rarities) do
counter += weight
if counter >= RandomNum then
local RarityTable = EggHatch.Pet[rarity]
local ColorTable = EggHatch.Color[rarity] -- problem here, it only grabs one value not the rest inside the table
print(RarityTable)
print(ColorTable)
local ChosenPet = RarityTable[math.random(1,#RarityTable)]
print(ChosenPet)
if ChosenPet then
FireShowcase:FireClient(plr, ChosenPet, Eg, ColorTable)
break
end
end
end
end
return EggHatch
-- This is an example Lua code block
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.