So recently, I’ve made a new table for a mining system I’m working on and for some reason after mining one rock, if you mine another rock it won’t drop any of the rock’s drops and I receive this error
After struggling for a good hour and researching optional solutions to this problem. I haven’t found any solution however and was hoping someone could help me out with this bug.
here’s the code
local function givereward(player, target) --probably pass the player here
local rock = RockMod.Rocks[target.Name]
--// NOTE TO SELF
-- Move lootgained table to spawn rock.
local lootgained = {}
for i,v in pairs(rock.Loot) do
table.insert(lootgained, i, v) lootgained[i].Amount = math.random(v.Amount[1], v.Amount[2]) --where the error occurs
end
local xpgained = math.random(rock.xp[1], rock.xp[2])
for i,v in pairs(lootgained) do
--print(v.Name,v.Amount, xpgained)
player.PlayerInfo.Levels.Exp.Value += xpgained
DropItem(target, v.Name,v.Amount)
end
table.clear(lootgained) --Clears all the Loot from the table
end