Insert a player name to tables

So im trying to add a player name into a table but with brackets around the name and any value after the brackets. ( [plr.Name] = 1 β†’ any value like boolean, string, number, etc. )

I already tried table.Insert but it gives out an error like below

if player then
  table.insert(serverbanned, [player.Name], true)  -- this is where it gives out the script error
  player:Kick("You were serverbanned from the game")
1 Like

You can just do player.Name instead of [player.Name]

need brackets cuz it wont read the player name when a player joins

--with no spaces

--with spaces

this is what i meant btw

local serverbanned = {
  ["PLR_NAME"] = true, -- this will appear when a player got banned
  -- and so on

As you see the first argument is the table that should be passed.
The second parameter takes the index at which the Variant value should be passed.
If no number pos is provided then I believe the number position the variant value gets stored at is

#self + 1  -- self referring to the table itself 

If you want to insert that player’s name and set it to true you can simply do this-

local s = player.Name
serverbanned[s] = true 

and by the way you are making serverbanned a dictionary and not a table.

aight i will try that

also. Oh its a dictionary