New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

How would I combine tables?

Asked by
M39a9am3R 3176 Moderation Voter Administrator Community Moderator Super Administrator
5 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 3176 — 3y

1 answer

Log in to vote
1
Answered by
adark 5391 Badge of Merit Moderation Voter Community Moderator
5 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 3176 — 5y
Ad

Answer this question