Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

Help, please.


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

4 comments

0

what are you trying to do?

0

oh I see now, you're attempting to edit a dictionary in _G? I would strongly recommend most any other method

0

make a table insert when a player joins

0

what is another method?

1 answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.