Hello! I would like to know how to know how to loop through 2 different tables.
Here is my wanted code I am making admin commands by the way:
commands.fling = function(sender,targetPlr1, targetPlr2,command)
for i, v in pairs(admins and specialAdmins) do
if sender.UserId == v then
if game.Players:FindFirstChild(targetPlr1) then
game.Players:FindFirstChild(targetPlr1).Character.HumanoidRootPart.Position =
game.Players:FindFirstChild(targetPlr1).Character.HumanoidRootPart.Position + Vector3.new(50,50,0)
end
end
end
end
end
And here is my tables:
local admins = {873724456}
local specialAdmins = {1624350571,873724456}
I tried the 2 table thing it did not work, well it gave an warning. I was thinking, maybe there is a proper way to do it.
I have already googled this.
PLEASE help I wish to make a ranking system, and this is required, because I use tables, if you have any help or an easier way to make my system, please do so!
Simplest way is just to loop through them individually. If you really don’t want to always loop through them. You can try creating a dictionary with the valid IDs as follows:
local admins = {"873724456"}
local specialAdmins = {"1624350571", "873724456"}
local admindicationary = {};
local specialadmindicationary = {};
local sender = 873724456
for i = 1, #admins do
admindicationary[admins[i]] = "admin";
end
for i = 1, #specialAdmins do --
specialadmindicationary[specialAdmins[i]] = "specialadmin";
end
if (admindicationary[tostring(sender)] or specialadmindicationary[tostring(sender)]) then
print("admin")
end
All this does is prevent the constant looping for an admin check.
plr.Chatted:Connect(function(msg)
local blah = msg:Split(" ")
local otherBlah = msg(prefix)
local targetPlayer1 = blah
local blah = blah
commands[otherBlah] (blah,otherBlah,targetPlayer1,blah)