local exampleTable = {
numbers = {1234, 4321}; --example numbers.
}
--yes, this table format is crucial to my goal.^^
game.Players.PlayerAdded:Connect(function(player)
for i,v in pairs(exampleTable) do
for _, id in pairs(v) do
if id == player.UserId then
--here. how do i get the name of the table the userid is found in, then convert it to a string?
end
end
end
end)
Any help is appreciated, ask all necessary questions.
On a dictionary, index is the name of the current variable. You can just set a StringValue’s value to it. Also, instead of looping I would use table.find() to check if the id exists on the array.
local exampleTable = {
numbers = {1234, 4321};
}
local StringValue -- path
game.Players.PlayerAdded:Connect(function(player)
for tablename, v in pairs(exampleTable) do
if table.find(v, player.UserId) then
print(tablename) -- numbers
StringValue.Value = tablename
end
end
end)