Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How would I combine tables?

Asked by
M39a9am3R 3210 Moderation Voter Community Moderator
10 years ago

I am trying to make a admin command script (I know ROBLOX has a ton of them) but I am wondering if it is possible to combine two tables for the script to look through at the same time? I am wanting to make a basic command such as kill and not have two chunks of a script to go through to run the command.

--All but my username is made up by the way.
local Administrators = {"M39a9am3R","Xaphier","MarxTheSpot","Coolio"}
local Moderators = {"Crazy","Mod1","gMod","Lol"}
for _,v in pairs(Administrators and Moderators) do
    print(v) --I made this so I could test the script to see if it will run through both tables.
end
0
test M39a9am3R 3210 — 8y
0
hello imKirda 4491 — 4y

1 answer

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

You have to run each loop separately, there's no way around that with how you've set up your permissions.

A solution to this is to create a combined Table for both Admins and Mods, which you can do easily, like so:

local Administrators = {"M39a9am3R","Xaphier","MarxTheSpot","Coolio"}
local Moderators = {"Crazy","Mod1","gMod","Lol"}
local AdminsAndMods = {}
for _, v in pairs(Administrators) do table.insert(AdminsAndMods, v) end
for _, v  in pairs(Moderators) do table.insert(AdminsAndMods, v) end

for _,v in pairs(AdminsAndMods) do
    print(v)
end
0
Alright, thank you. M39a9am3R 3210 — 10y
Ad

Answer this question