saving a steamID in a table?

I want my code to loop through a table, setting all the saved SteamID’s players to teleport somewhere. How would I do that?

	if
		MonsAm == 0 then
		print("killedallmonsters")
		for i=1,PlayerAm do
		names*:SetPos(Vector(0,0+(i*100),0))
            end

Error I get is :
bad key to string index (number expected, got string)

I know I have to input a number value behind SetPos(), but I really have no clue how to derive one from a table.

Thanks

Edit: SteamID’s are saved in to the table

Edit: Can you even use SteamIDs to teleport???

Just use the entity, not the steamID unless you’re saving the table for future (read: long enough that they reconnect) use.

How would I go about putting the Entity in a table?

What is the condition you are selecting players based on? You shouldn’t even have to define a new table.



for k,v in pairs(player.GetAll()) do if v:IsAlive() then v:SetPos(Vector(0,0+(k*100),0)) end end


It’s set so only a certain amount of people are teleported, in which case their EntID is stored in a table, the code reads that table and teleports all players inside the table somewhere.

The conditions are set by the players putting themselves inside the table with a concommand, so GetAll() doesn’t work in this case.

I used :

		names[PlayerAm] = pl:GetByIndex()

still no fish ):

Personally I’d just set a variable like Player.WillBeTeleported and clear it end of round. If you’d like to use a table, table.insert is your friend and then a k, v statement when you’d like to loop through the table.

As for calling the player, you seem to have mistaken the need to use their index etc. They are an entity. Simply add them to the table, and then call them as an entity. No need to getbyindex, etc.

Just do table.insert(names, pl) instead.

Then later you can do
[lua]for _, v in ipairs(names) do
v:SetPos(Vector(0,0+(i*100),0))
end
[/lua]

Remember to clear your table afterwords or the old people will get teleported.