I’m attempting to try and log the bans for my admin gui, why is this error happening?
-- self explanatory, bans the player
function BanModule:BanPlayer(player, reason, staff)
local success, result = pcall(function()
return Players:GetUserIdFromNameAsync(tostring(player))
end)
if success then
local PlayerToBan = Players:GetPlayerByUserId(result)
local data = StatsManager:GetData(PlayerToBan)
if data.IsBanned == false then
data.IsBanned = true
data.BanReason = reason
data.BannedByWho = staff.Name
PlayerToBan:Kick(string.format("\n\nYou've been banned for the reason: \n\n" .. data.BanReason))
local AvatarThumbnail = string.format(Format, result)
local TimeFormat = os.date("%I:%M | %x")
local data = {
["embeds"] = {
["author"] = {
["name"] = PlayerToBan.Name;
["icon_url"] = AvatarThumbnail
};
["title"] = "A player has been banned.";
["description"] = PlayerToBan.Name .. " has been banned.";
["type"] = "rich";
["fields"] = {
{
["name"] = "Username";
["value"] = "[Click to visit player profile](https://www.roblox.com/users/" .. result .. "/profile)";
["inline"] = true
};
{
["name"] = "UserID";
["value"] = result;
["inline"] = true
};
{
["name"] = "Time";
["value"] = TimeFormat;
["inline"] = true
}
}
}
}
local FinalizedData = HttpService:JSONEncode(data)
HttpService:PostAsync(Webhook, FinalizedData)
else
return false
end
else
error("There was an error fetching the UserId from a user's username: " .. result)
end
end