So, I basically need to see if a name exists in a table, but I can't iterate through all the values. Is it possible?
✓ ANSWER ACCEPTED
How can I see if a name exists in a table, without having to iterate through every value?
1 answer
✓ Accepted answer
local PlayersData={
['MessorAdmin'] = "derp";
['AwseomeSpongebob'] = "Hellooooooo? nub?"
}
-- Alright, here's our table.
We want to print our data right? Lets go ahead and do that now. There's a few different ways. Way 1:
Not meant for new games, it's deprecated.
table.foreach(PlayerData, print)
Way 2:
for i,v in next,PlayerData do
print(i, v)
end
Way 3: Now, if you don't want to go all the way through all the datas just use this.. But be careful, this is prone to errors.
local Result;
if PlayersData['MessorAdmin'] then
Result = PlayersData['MessorAdmin']
else
Result = "Aww :("
end
print(Result)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
[ALERT I TOLD HIM TO MAKE THE QUESTION DUE TO IT WAS IN THE CHAT]