I’ve restarted work on a mining game I was working on before, in order to change up the systems to be more optimized and less complicated to work with.
There’s this function in one of the scripts and it referred to a dictionary. The dictionary used to look like this
Ore.Info = {
["Stone"] = {
Cash = 1;
Health = 3;
Depths = {
Min = 0;
Max = 100;
};
Rarity = 0;
};
["Copper"] = {
Cash = 3;
Health = 5;
Depths = {
Min = 5;
Max = 100;
};
Rarity = 950;
};
["Demon"] = {
Cash = 3;
Health = 5;
Depths = {
Min = 101;
Max = 10000000;
};
Rarity = 0;
};
};
it worked perfectly fine.
But then I changed it up to be like this
local Ore.Info = {};
for _, oreInst in ipairs(game.ReplicatedStorage.OresFolder:GetChildren()) do
if oreInst:IsA("Model") then
oColor = oreInst.PrimaryPart.Color
else
oColor = oreInst.Color
end
if not table.find(Ore.Info, oreInst.Name) then
Ore.Info[''..oreInst.Name..''] = {Inst = oreInst, OreColor = oColor, Depths = {Min = oreInst.Min.Value; Max = oreInst.Min.Value;}, Rarity = oreInst.Rarity.Value, StringRare = oreInst.StringRare.Value}
end
end
And now it gives me an error
This is what the function looks like
function PickOre(layer)
local gotOres = {}
local Y = math.abs((layer.Y-Origin.Y)/6)
for i,v in pairs(Ore.Info) do
if Y >= v.Depths.Min and Y <= v.Depths.Max then
gotOres[i] = v.Rarity
end
end
local Rarity = math.random(0,1000)
local GotFirstNumber
local Sames = {}
for i,v in sortedpairs(gotOres, function(t,a,b) return t[b] < t[a] end) do
if v <= Rarity then
GotFirstNumber = v
for ii,vv in pairs(gotOres) do
if vv == GotFirstNumber then
Sames[#Sames+1] = ii
end
end
break
end
end
local GetFinalOre = Sames[math.random(#Sames)]
local MakeOre = game.ReplicatedStorage.OresFolder:FindFirstChild(GetFinalOre):Clone()
return MakeOre
end
if anyone could help I would appreciate it