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

How do I print a string in a table?

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)

2 comments

0

... you mean to print the index of a dictionary? Why would you?

0

I guess I mean that... I want to know how to print it.

1 answer

✓ Accepted answer
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

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