Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

for i,v in pairs how to add player names?

Salutations, dear reader! I am making a script, where it checks your name and it executes a command then, with for i,v in pairs. Here is my script:

		for i,v in pairs (Premium) do
			if v == player.Name then

How could I add the player names to the Premium for i,v table? I couldn't figure it out, I am thankful for every little help I can get! Thank you again, and have a nice day!

3 answers

Sounds like table.insert would be something of interest.

table.insert(table,value)

or

table.insert(table,index,value)

Without index, itll just do #table+1.

2 comments

0

Oh, but where would I write the names?

0

you'd just insert the names where it says value

For the answer above me:

Write the names into table like that:

table.insert(table,  player.Name)

Hey there! To accomplish this, you have a few options! The one I recommend is to make table. Here is how it would look like.

-- I will use tester as an example
local Testers = {"you","Your friend" }
local Players = game:GetService('Players')
Players.PlayerAdded:Connect(function(plr)
  if Testers[plr.Name] then
    for i, v in pairs(Premium)
       print(v.Name)
    end
  end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.