Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I print a string in a table?

Asked by
FiredDusk 1466 Moderation Voter
8 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.

I am trying to print "Player" and "PreyStar" from the table below but Idk how to. Thanks for the help!

Admins = {['Player'] = true, ['PreyStar'] = true}
print(Admins[1].Name)
0
... you mean to print the index of a dictionary? Why would you? XAXA 1569 — 8y
0
I guess I mean that... I want to know how to print it. FiredDusk 1466 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago
local Admins = {['Player'] = true, ['PreyStar'] = true} --a table of admins

for i, v in pairs(Admins) do --cycle through all values in the table, where i = index and v = value.
    print(i) --print the index, or name of the player.
end

Note this is not recommended if you are trying to make an admin script, as people can change usernames. it's better to use the player's id over their username. You can find the id, as it is a property of the player.

local id = game.Players.Player.userId

Ad

Answer this question