Attempt to index string with number error

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to fix my code.
  2. What is the issue? Include screenshots / videos if possible!
    The issue is that I do not understand why it sends me an error.

    image
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Asking others, youtube and google did not help me in any way. Yeah, I did look in the Developer Hub, still did not find an answer.

x contains an user ID. Which is a number. But I am trying to assign to the X few more things, sadly, unsuccessfully.

Can you show us the script? I can take a look and see if I can figure it out.

If allData[x] is a number, of course it won’t work, it’s a number, not a table. What are you trying to do?

2 Likes

Sure!

I am trying to add to the X few more things. Such as codes.

What’s the PlayersInside variable and what does it store, or what’s it supposed to store?

Oops. It is string. Firstly I wanted to make it a number, but then changed my mind.

PlayersInside is a table. It contains players. There is no problem with that.

I want to thank you, because by that instead of doing

allData[x] = v.Name
-- I have done:
allData[x] = {v.Name}

Which fixed the whole thing, thank you!

1 Like