[Resolved] How To Skip Over A Value In An Array Within A For I, V Loop?
Asked by
4 years ago Edited 4 years ago
I'm working on a script that gives items to the player when an enemy is killed. It also can give items at a chance such as having a 10% chance to get a legendary sword. Here's how I organize the loot table for my mobs.
04 | true , { "Blizzard Striker" , { 1 , 1 } } , |
05 | { "Glaciersteel Cleaver" , { 3 , 10 } } , |
Here is the item drop script.
01 | local MobConfig = require(script.Parent.MobConfig) |
02 | local Mob = script.Parent |
03 | local Enemy = Mob.Enemy |
06 | if (Mob = = nil ) or (Enemy = = nil ) then return end |
07 | if ( not Enemy:FindFirstChild( "Player_Tag" )) then return end |
08 | local Tag = Enemy:FindFirstChild( "Player_Tag" ) |
09 | if ( not Tag) and ( not Tag.Value) then return end |
11 | local BP = plr.Backpack |
12 | local SG = plr.StarterGear |
13 | for i, v in pairs (MobConfig.DropsWeapon) do |
15 | if MobConfig.WeaponDirectory:FindFirstChild(MobConfig.DropsWeapon [ i ] [ 1 ] ) then |
16 | local DropChance = Random.new():NextInteger(MobConfig.DropsWeapon [ i ] [ 2 ] [ 1 ] , MobConfig.DropsWeapon [ i+ 1 ] [ 2 ] [ 2 ] ) |
17 | if MobConfig.DropsWeapon [ i ] [ 2 ] [ 1 ] = = DropChance then |
18 | print ( "Drop Chance Check" ) |
20 | if SG:FindFirstChild(MobConfig.DropsWeapon [ i ] [ 1 ] ) or BP:FindFirstChild(MobConfig.DropsWeapon [ i+ 1 ] [ 1 ] ) then return end |
21 | local W 1 = MobConfig.WeaponDirectory [ MobConfig.DropsWeapon [ i ] [ 1 ] ] :Clone() |
22 | local W 2 = MobConfig.WeaponDirectory [ MobConfig.DropsWeapon [ i ] [ 1 ] ] :Clone() |
32 | if MobConfig.DropsWeapon [ 1 ] = = true then |
33 | print ( "Checked for a drop" ) |
34 | Enemy.Died:Connect(DropItem) |
The issue is whenever I use "i", the script errors with:
Attempt to index bool with number on line 15
. Is it possible to skip over the first value in the droptable (true)?