Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I combine tables?

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

2 comments

0

test

0

hello

1 answer

✓ Accepted answer

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

1 comment

0

Alright, thank you.

This discussion is preserved as it was. New answers, comments, and votes are closed.