Help with inserting table into another table?

  1. What do you want to achieve? Keep it simple and clear!

I want to, using a moderation system modulescript im making, insert a table using a function into the module script on the server to set admins.

  1. What is the issue? Include screenshots / videos if possible!

Its quite hard to explain and I dont even know what the issue is, no errors, and my print statement debugging only shows 1 value.

Here is the function in the module script

	function ModService:SetAdmins(admins)
		if type(admins) == "table" then
			for i,_ in pairs(admins) do
				table.insert(admintable,admins[i])
				return admintable -- thats there because debugging, admintable is a predefined variable, i just haven't shown it here
			end
		else
			warn("function ModService:SetAdmins() arguement 1 is a "..type(admins)..", not a table")
		end
	end

Here is the server script:

local ModerationService = require(game.ReplicatedStorage.ModerationService)
local myAdmins = {
	1274272423,
	5052029921
}

local test = ModerationService:SetAdmins(myAdmins)
print(test)

This is the output
image

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Nothing worked.

because youre returning the table after adding 1 id

	function ModService:SetAdmins(admins)
		if type(admins) == "table" then
			for i,_ in pairs(admins) do
				table.insert(admintable,admins[i])
			end
            return admintable -- thats there because debugging, admintable is a predefined variable, i just haven't shown it here
		else
			warn("function ModService:SetAdmins() arguement 1 is a "..type(admins)..", not a table")
		end
	end
1 Like

Forgot to say this, but it returns as a dictionary and I don’t exactly like that (me nitpicking), I thought it might just be the output saying that but im not sure. Any way to fix?

i think its just the output window doing that, does that to all types of tables

1 Like

got it, thanks!

(character limit go brrrrrrr)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.