Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

What does this error attempt to index global 'items' (a function value) mean and how do I fix it?

Asked by 5 years ago

11:42:05.548 - Players.VECTORGRAPHIC.PlayerGui.ScreenGui.newshop:109: attempt to index global 'items' (a function value)

This is what items is

```lua items={

{"Sword",50,"http://www.roblox.com/asset/?id=32801243",

"Buying this will increase the rate at which you dig by 150 percent. This can be very useful when mining for points."},

{"DarkHeart",1000,"http://www.roblox.com/asset/?id=32801656",

"Buying this will increase the damage that you deal with the swuvle by 150 percent. This can be very useful when sword fighting."},

{"Sniper+",100,"http://www.roblox.com/asset/?id=32801218",

"The top grade sniper reloads 150 percent faster aswell as dealing 150 percent more damage than the normal sniper. This new sniper will replace your old one."},

{"Medkit",100,"http://www.roblox.com/asset/?id=32801669",

"After buying, you will find that you spawn with one medkip. A medkip can be used once, in battle, to fully heal you. Medkips can be very useful when getting away with the enemy flag. i herd u liek medkipz?"}, }

--here is what errors lua sp.Store.InfoBox.Title.Text=items[selected][1]

0
Can you provide what "selected" is? I feel like a lot of code here is missing. UnderWorldOnline 59 — 5y

1 answer

Log in to vote
0
Answered by
Fifkee 2017 Community Moderator Moderation Voter
5 years ago

Somewhere in your code, the variable "items" is being defined as a function.

Skim through your code and make sure that the variable is unique, and nothing else is overwriting the variable.

Here's a tip: If lua ever says you're trying to index something invalid, you're probably trying to path a variable / object that is nil, or doesn't have a path.

For example, you can't do this:

```lua function a() end

print(a.waffle) ``` because "a" is a function, and it has no path. Doing this will throw the error that you're getting right now.

However, you can do this:

```lua local Table = { A = { B = { C = 'waffle' } } }

print(Table.A.B.C) ``` because the Table can be indexed and pathed like how you would when you're browsing through workspace, or anywhere else.

You also cannot do this:

lua local NilValue = nil; print(NilValue.Descendant)

as it will throw an "attempt to index local NilValue ( a nil value)" error. Good luck!

Ad

Answer this question