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

[HELP] I'm getting a attempt to index field '?' (a nil value) error!

Asked by 5 years ago
Edited 5 years ago

Help, please.


game.Players.PlayerAdded:Connect(function(plr) table.insert(_G.CashData,plr.Name) table.insert(_G.CashData[plr.Name],0) end)
0
what are you trying to do? vanilla_wizard 336 — 5y
0
oh I see now, you're attempting to edit a dictionary in _G? I would strongly recommend most any other method vanilla_wizard 336 — 5y
0
make a table insert when a player joins suphaninjap221 -9 — 5y
0
what is another method? suphaninjap221 -9 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Well, it seems you are new to using tables so let me go ahead and fix it up for you...

game.Players.PlayerAdded:Connect(function(plr)
    _G.CashData[plr.Name] = 0
end)

Alright, so the correct way to use table.insert is if you are going to insert a single value or table without a indexed name. But for this, it does have a indexed name which is the players name.

I'm kind of busy so I can't really go into depth but if you have any other questions let me know.

Ad

Answer this question