Awkward issue with table index being nil

Hi, so I’m trying to find out the reason behind why the player’s table inside of player_tool_data is non-existent, and I’m trying to grind through this project quickly so I figured I’d make a post.

Here’s my code, I made it a pastebin to keep the indentation and make it more readable:
https://pastebin.com/jjavDgdh

The issue is when I attempt to index player.Name in the player_tool_data table from the Create_Tools function, it returns nil. Very confused by this actually…

Help appreciated, thanks.

Is is possible that Create_Tools is being called before Create_Player_Data?

1 Like

I did think about that, so I added a 10 second delay in my PlayerAdded function before it’s called, and the same result occurs…

Wow, I’m stupid.

I didn’t actually include this part of my code, but for whatever reason I wrote it out like this in the PlayerAdded function I had:

player_tool_data[player.Name] = Create_Player_Data(player)

When I wrote up the Create_Player_Data function, I had it set it automatically, so it returns no value, therefor erasing the newly made key it just made to the table…
:neutral_face:

Thanks for the replies though, I appreciate it :slight_smile:

2 Likes