What do you want to achieve?
I have a whitelist of players in a table, and i want to loop through them on PlayerAdded to see if the players id matches the one in the table, after that clone a spell that is whitelisted for that specific player and parent it to their gui.
What is the issue?
Don’t know how to loop through a table properly.
What solutions have you tried so far?
Tried going through devforum to see if people had similar problems like me, and haven’t got anything
-- Portion of the spells whitelist:
local SpellWhitelist = {
[12625702] = {"All"}
[32581425] = {"All"};
[64237575] = {"AdminSpells"};
[4759789373] = {"AdminSpells"};
[128046674] = {"AdminSpells"};
[142828340] = {"All"};
}
--Loop that i pathetically tried using:
for index, ids in pairs(SpellWhitelist) do
if index == player.UserId then
for index2, spells in pairs(ids[index]) do
local ExtraSpell = script.ExtraSpell
if ExtraSpell then
print(SpellWhitelist)
ExtraSpell:Clone()
--ExtraSpell.title.Text = ids[index2]
ExtraSpell.Parent = SpellBook
end
end
end
end
As i explained in my post, my expected result is to loop through that table, and if the id of the player matches the id in the table, it will give him the spells which his id is equal to.
-- Portion of the spells whitelist:
local SpellWhitelist = {
[12625702] = {"All"}
[32581425] = {"All"};
[64237575] = {"AdminSpells"};
[4759789373] = {"AdminSpells"};
[128046674] = {"AdminSpells"};
[142828340] = {"All"};
}
--Loop that i pathetically tried using:
for index, ids in pairs(SpellWhitelist) do
if index == player.UserId then
for index2, spells in pairs(ids) do
local ExtraSpell = script.ExtraSpell
if ExtraSpell then
print(SpellWhitelist)
ExtraSpell:Clone()
--ExtraSpell.title.Text = ids[index2]
ExtraSpell.Parent = SpellBook
end
end
end
end