1

# How can I use table.insert when I don't know the index number?

I want to create something inside of a table when a function is triggered, I also don't know it's index number. How can I get Roblox to print the newly added thing in the table?

local Players = game.Players

PlayerList = {}

table.insert(PlayerList,1,player.name)
end)

print(PlayerList[1]) --- I don't know the index number.


I mainly want to know how to print the index number, any other mistake is most likely a typo (If not please point it out).

1
If you want the last value in your Table you can do print(PlayerList[#PlayerList]) Is that what you wanted? Spjureeedd 363 — 22d
1
And as for you Players variable, I would suggest you do game:GetService("Players") instead of just game.Players Spjureeedd 363 — 22d

1
Xapelize 1459
22 days ago
local Players = game:GetService("Players")

PlayerList = {}