How to have an array inside of an array

I’m trying to make a banning system that logs bans to discord.

I’m trying to get my array to look like this:

local Banned= {
	{
		['name'] = "AvacadoMan",
		['value'] = "Was permanently banned for disturbing the peace"
	},
	{
		['name'] = "Nick",
		['value'] = "Was temporarily banned for 365 days for being mean"
	},
}

I have tried multiple different ways of putting the variables in that way such as

local Banned = game:GetService("HttpService"):JSONDecode(DS:GetAsync("Banned")) 
--just a blank array
local NewBan = {
		['name'] = " Name Var ",
		['value'] = " Reason var "
	}
Banned[ ID Var ] = NewBan

And

local Banned = game:GetService("HttpService"):JSONDecode(DS:GetAsync("Banned"))
--just a blank array
local NewBan = {}
NewBan['name'] = ' Name var '
NewBan['value'] = ' Reason var '
TestBanArray[ ID var ] = NewBan	

Every time I test it it bans the person but the array with the reason is nil, or I get a 404 error from discord and the array with the reason is nil.

Sometimes the webhook works but its blank
image_2023-11-26_184420224

Here’s my full script and a screenshot of GUI:

Main banning script

local DS = game:GetService("DataStoreService"):GetDataStore("BanService")
local re = game.ReplicatedStorage.Banned
local HTTPService = game:GetService("HttpService")
local hook = "https://webhook.newstargeted.com/api/webhooks/1176056359406546944/NQ-dvrUsOk16eJByFXQlv1Mf9eP4U07zZJYIrOu111c-IKGKc1qGDZ0fl0qYY6wtUyvX"

game.Players.PlayerAdded:Connect(function(player)
	local Banned = game:GetService("HttpService"):JSONDecode(DS:GetAsync("Banned"))

	for BID, Reason in pairs(Banned) do
		
		if player.UserId == tonumber(BID) then
			player:Kick(Reason[2])
		end

	end
	
	
end)

re.OnServerEvent:Connect(function(Player, Guy, Reason)
	print(tostring(Guy).." | "..tostring(Guy).." | "..Reason)
	
	if Guy and Player:GetRankInGroup(15409427) > Guy:GetRankInGroup(15409427) and Player:GetRankInGroup(15409427) > 252 then
		
		local Banned = game:GetService("HttpService"):JSONDecode(DS:GetAsync("Banned"))
		local NewBan = {}
		NewBan['name'] = Guy
		NewBan['value'] = Reason
		
		Banned[Guy.UserId] = NewBan	
		print(NewBan[1])
		print(Banned[Guy.UserId])
		DS:SetAsync("Banned",game:GetService("HttpService"):JSONEncode(Banned))
		Guy:kick(Reason)
		
		local data = {

			['embeds'] = {{

				['title'] = "Ban List [UPDATED]",
				['description'] = "All banned players are below",
				['fields'] = Banned


			}}

		}

		local finaldata = HTTPService:JSONEncode(data)
		HTTPService:PostAsync(hook, finaldata)
		
	end
	
end)

Local script

local Player = game.Players.LocalPlayer
local PlayerGui = Player.PlayerGui 
local re = game.ReplicatedStorage.Banned
local Players = game:GetService('Players')

function leftclick()
	local Kicke = Players:FindFirstChild(PlayerGui.ScreenGui.Frame.BanText.Text)
	local Reason = PlayerGui.ScreenGui.Frame.BanReason.Text
	
	re:FireServer(Kicke,Reason)
end

script.Parent.MouseButton1Click:Connect(leftclick)

GUI

I hope that someone knows how to do this or else my system will be toast.

I’d take a look at dictionaries, as they allow you to label values and give them attributes.

I found out the issue, since the players id was a large number the first thing in the array is nil so the webhook does not send, if i change it to start with 1 and then 2 then 3, then it works.

you sent your webhook here please change it for security

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