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")
end
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
table.insert(serverbanned,s)
serverbanned[s] = true
and by the way you are making serverbanned a dictionary and not a table.