How would I script this UnBan GUI?

Hello everyone, I am here asking: How would I make my script be able to load banned players with their reason on to a gui?

Here is my current script: (Server Script)

local discordWebHook = require(workspace.DiscordWebhook)

local hook = discordWebHook.new('Nope', 'Nope')

local formatHelper = hook:GetFromatHelper()

local avatarUrl = game:GetService('Players'):GetUserThumbnailAsync(1, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)

local DSS = game:GetService("DataStoreService")

local allowedToUse = ({
	"MrOofBoyPlayz",
	"BigBanHam"
})

local Bans = DSS:GetDataStore("Bans_[Code Censored]")

game.Players.PlayerAdded:Connect(function(player)
	for _, plr in pairs(allowedToUse) do
		if player.Name == plr then
			script.AdminTools:Clone().Parent = player.PlayerGui
		end
	end

	local data

	local s, e = pcall(function()
		data = Bans:GetAsync(player.UserId)
	end)

	if data ~= nil then
		local bannedGui = script.Banned:Clone()
		bannedGui.Parent = player.PlayerGui
		bannedGui["3"].Text = "More details: "..data
		wait(6)
		player:Kick()
	end
end)

game.ReplicatedStorage.Ban.OnServerInvoke = function(player, playerToBan, reason)
	if player.Name == playerToBan then
		return "You can't ban yourself!"
	end
	
	if playerToBan == "MrOofBoyPlayz" then
		Bans:SetAsync(player.UserId, "Do NOT attempt to ban the owner.")
		local bannedGui = script.Banned:Clone()
		bannedGui.Parent = player.PlayerGui
		bannedGui["3"].Text = "More details: Do NOT attempt to ban the owner."
		wait(6)
		player:Kick()
	end

	for _, plr in pairs(allowedToUse) do
		if player.Name == plr then
			local realPlayer = game.Players:FindFirstChild(playerToBan)
			if realPlayer then
				Bans:SetAsync(realPlayer.UserId, reason)
				local bannedGui = script.Banned:Clone()
				bannedGui.Parent = realPlayer.PlayerGui
				bannedGui["3"].Text = "More details: "..reason
				wait(6)
				realPlayer:Kick()
				local msg = hook:NewMessage()

				msg:Append(playerToBan.." was banned by "..player.Name..". Reason: "..reason)
				msg:SetUsername("User Banned")
				msg:SetAvatarUrl(avatarUrl)
				msg:SetTTS(false)
				msg:Send()
				return "Banned succesfully!"
			else
				return "Error: Player doesn't exist."
			end
		else
			Bans:SetAsync(player.UserId, "Exploiting")
			local bannedGui = script.Banned:Clone()
			bannedGui.Parent = player.PlayerGui
			bannedGui["3"].Text = "More details: Exploiting"
			wait(6)
			player:Kick()
			local msg = hook:NewMessage()

			msg:Append(player.Name.." **TRIED** to ban "..playerToBan.." lol.")
			msg:SetUsername("Exploiter Catched")
			msg:SetAvatarUrl(avatarUrl)
			msg:SetTTS(false)
			msg:Send()
		end
	end
end

game.ReplicatedStorage.Unban.OnServerInvoke = function(player, playerToUnban)	
	for _, plr in pairs(allowedToUse) do
		if player.Name == plr then
			local realPlayer

			local pcall = function()
				realPlayer = game.Players:GetUserIdFromNameAsync(playerToUnban)
			end
			
			if realPlayer == nil then
				return "Error."
			end

			local reason = Bans:GetAsync(realPlayer)
			if realPlayer then
				Bans:RemoveAsync(realPlayer, reason)
				local msg = hook:NewMessage()

				msg:Append(playerToUnban.." was unbanned by "..player.Name..".")
				msg:SetUsername("User Unbanned")
				msg:SetAvatarUrl(avatarUrl)
				msg:SetTTS(false)
				msg:Send()
				return "Unbanned succesfully!"
			else
				return "Error."
			end
		else
			Bans:SetAsync(player.UserId, "Exploiting")
			local bannedGui = script.Banned:Clone()
			bannedGui.Parent = player.PlayerGui
			bannedGui["3"].Text = "More details: Exploiting"
			wait(6)
			player:Kick()
			local msg = hook:NewMessage()

			msg:Append(player.Name.." **TRIED** to unban "..playerToUnban.." lol.")
			msg:SetUsername('Exploiter Catched')
			msg:SetAvatarUrl(avatarUrl)
			msg:SetTTS(false)
			msg:Send()
		end
	end
end
1 Like

Change the table named allowedToUse to not use parentheses. Only use braces.

1 Like

This is the wrong category then. Scripting support is used if you need help and you have attempted to solve it before.

1 Like

Anyways, I will attempt to do it myself but if I make an error then I will request some help

Nope, I won’t be able to do this, I need someone to start me off here :confused: