# [HELP] Index a boolean value

## Recommended Posts

Hello guys, I got this inventory system from community but I get an error when opening the inventory panel:

```local aktuel,oldaktuel = "Potte","Potte"

function showInventar(teil)
if(type(teil) == "string" and teil ~= "i") then
aktuel = teil
end
unbindKey("i","down",showInventar)
bindKey("i","down",destroyInventar)
showCursor ( true ,false)
toggleControl ( "fire", false)
pClose,pMove,pReset = "images/closeinv.png","images/moveinv.png","images/reset.png"
r,g,b = { ["Potte"]=110,["Taschen"]=110,["Keys"]=110,["Waffen"]=110, ["Rahmen"]=255} , { ["Potte"]=110,["Taschen"]=110,["Keys"]=110,["Waffen"]=110 ,["Rahmen"]=255} , { ["Potte"]=110,["Taschen"]=110,["Keys"]=110,["Waffen"]=110,["Rahmen"]=255 }

slots = tonumber(getElementData(getLocalPlayer(),"Inventar_c")[aktuel.."Platz"])
lines = math.ceil(slots/7)
bx,by = 330, 20 - 4 + 45*lines --543,266
if(not x and not y) then
x,y = fx/2 - bx/2,fy/2 - by/2
end
r[aktuel],g[aktuel],b[aktuel] = 0,255,0
r["o"..aktuel],g["o"..aktuel],b["o"..aktuel] = 0,255,0
local line
local oline
local platz

for i=0,slots-1,1 do
line = math.floor(i/7)
if(line ~= oline) then
platz = 0
end
btn_inventar[aktuel][i] = guiCreateButton (x+10 + 40 * platz + 5 * platz,y+10 + 40 * line + 5 * line,40,40, i.."", false)
guiSetAlpha(btn_inventar[aktuel][i],0)
local id
if( getElementData(getLocalPlayer(),"Item_"..aktuel.."_c") ) then
id = getElementData(getLocalPlayer(),"Item_"..aktuel.."_c")[i.."_id"]
if(id) then
item[id]= { ["x"]= x+10 + 40 * platz + 5 * platz ,["y"]=y+10 + 40 * line + 5 * line }
itemFront[id] = false
end
end
if(not lockItemUseState[aktuel] or not lockItemUseState[aktuel][tonumber(i)]) then
setItemRGB(i,110,110,110)
end
sitem[i]= { ["x"]= x+10 + 40 * platz + 5 * platz,["y"]=y+10 + 40 * line + 5 * line }
oline = line
platz = platz + 1
end

btn_Potte = guiCreateButton (x+2,y-48,80.0,48.0, "", false)
guiSetAlpha(btn_Potte,0)
btn_Keys = guiCreateButton ( x+2 + 82,y-48, 80.0,48.0, "", false )
guiSetAlpha(btn_Keys,0)
btn_Taschen = guiCreateButton ( x+2 + 82*2,y-48, 80.0,48.0, "", false )
guiSetAlpha(btn_Taschen,0)
btn_Waffen = guiCreateButton ( x+2 + 82*3,y-48, 80.0,48.0, "", false )
guiSetAlpha(btn_Waffen,0)
btn_Close = guiCreateButton ( x+bx + 1,y-49, 18,18, "", false  )
guiSetAlpha(btn_Close,0)
btn_Move = guiCreateButton ( x+bx + 1,y-49+18, 18,18, "", false )
guiSetAlpha(btn_Move,0)
btn_Reset = guiCreateButton ( x+bx + 1,y-49+36, 18,18, "", false )
guiSetAlpha(btn_Reset,0)

end
```

I get an attempt to index a boolean value here:

```slots = tonumber(getElementData(getLocalPlayer(),"Inventar_c")[aktuel.."Platz"])
```

Any ideas what's wrong with it?

```slots = ( getElementData(getLocalPlayer(),"Inventar_c") and tonumber(getElementData(getLocalPlayer(),"Inventar_c")[aktuel.."Platz"]) )
```

I think you don't have bag or something like that

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• #### Social Media

×
• Create New...