hi folks!
trying to make a randomized loot generation system
im looping through all spawn points on the map, then if the item does spawn (1/3 chance) it goes through with this:
for i, v in pairs(mapItemSpawns:GetChildren()) do
local rand = math.random(1,3) -- // 33% Chance of item spawn
if rand == 3 then -- // Item Spawn
local curr = 0
local ran = Random.new()
local num = ran:NextNumber(0, total)
print(total)
for key, value in pairs(tempItem) do
print(tempItem)
print(tempItem[key], ":", tempItem[value])
curr += tempItem[value]
if num > curr then
continue
else
local rarity = curr
print(rarity)
break
end
end
end
end
but in the second loop (key, value), i can only get the “key” and its not even the key, its the value.
currently the dict looks similar to this:
tempItem = {
["Common"] = 0.9,
["Elite"] = 0.1,
}
so on so forth with different rarities.
when i print the key and value i get:
0.1 : nil
at a complete loss as to why this is happening, so any help is appreciated ![]()