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
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.