I have a script that I use for detecting suspicious activity on the client, and then that information is sent via a remote to the server, where a “log” is created that creates a post sent to my Discord server (using a Proxy) that also then kicks the suspected exploiter all on the server.
Previously, my anti-exploit kicked players on the client, but this didn’t allow for me to measure/log people who got booted.
This logging script I have used in other games, and it has worked before. Initially, I thought that it was something wrong with the Webhook/Proxy, but I did some test messages, and those went through. I have a couple of print statements inside the code that is supposed to print when the logger is activated, but they don’t print! And stranger, the player still gets kicked with this code, despite everything else not working!
Here is the following code:
--- this is the code that activates when the player exploits
game.ReplicatedStorage.playerEvents.kick.OnServerEvent:Connect(function(player,reason,Type,kick,ban,msg)
print(tostring(player),tostring(reason),tostring(Type),tostring(ban),tostring(kick),tostring(msg))
--- above print statement doesn't work, but apparently it still fires the below source of code
logger.new(player,reason,Type,kick,ban,msg)
end)
--- here is the code from the log module
local HTTPService = game:GetService("HttpService")
local autoBanAccountAge = false --- set to true if needed.
local autoBanMinAge = 30
local log = {}
log.__index = log
function log:sendSpawnKill()
end
function log:sendTeamKill()
end
function log:sendExploit()
print("Logging Started")
local link = "" --- the link to the webhook and proxy would be here. it works, but for security purposes, I am censoring it on this post
local post ={
["username"] = "Officer Johnny";
--["content"] = "",
["embeds"] = {{
["title"] = "**Player kicked from World War Tycoon "..tostring(self.gameType).."**",
["description"] = tostring(self.player.Name).." was kicked for malicious activity",
["type"] = "rich",
["color"] = tonumber(0xFF8C00),
["fields"] = {
{
["name"] = "reason",
["value"] = tostring(self.reason),
["inline"] = true
},
{
["name"] = "server id",
["value"] = tostring(self.server),
["inline"] = true
},
{
["name"] = "banned?",
["value"] = tostring(self.ban),
["inline"] = true
},
{
["name"] = "kicked?",
["value"] = tostring(self.kick),
["inline"] = true
},
{
["name"] = "plr UserId",
["value"] = tostring(self.id),
["inline"] = true
},
{
["name"] = "Account Age",
["value"] = tostring(self.age),
["inline"] = true
},
{
["name"] = "**Link to Profile**",
["value"] = "https://www.roblox.com/users/"..self.id.."/profile",
["inline"] = true
},
},
}},
print("Embed Made")
}
local Data = HTTPService:JSONEncode(post)
HTTPService:PostAsync(link, Data);
if self.kick == true then --- this gets executed though!
if self.msg ~= nil then
self.player:Kick(tostring(self.msg))
else
self.player:Kick("You have been kicked for suspected exploiting.")
end
end
end
function log:ban()
---un used for now
end
function log.new(player: "instance, the suspected player",
reasoning: "why is this being sent? a brief description of why",
Type: "exploit, spawnKill, teamKill, or injection",
kick: "true or false, nil defaults to false",
ban: "true or false, nil defaults to false.",
customMSG: "custom kick message.")
if ban == nil then
ban = false
end
if kick == nil then
kick = false
end
local gameInfo = game:GetService("ReplicatedStorage"):WaitForChild("gameInfo")
local serverType = nil
if gameInfo:GetAttribute("vipServer") == true then
serverType = "VIP Server"
elseif gameInfo:GetAttribute("maxPlayers") == 2 then
serverType = "2 Player Version"
else
serverType = "Single Player Version"
end
print(player.Name.." has generated a log!") --- this doesn't print.
local self = setmetatable({
player = player,
reason = reasoning,
id = player.UserId,
age = player.AccountAge.. " Days",
--account = "https://www.roblox.com/users/"..player.UserId.."/profile",
gameType = serverType,
server = game.JobId,
ban = false,
msg = customMSG,
}
,log)
if autoBanAccountAge == true and Type == "exploit" then
if self.age < autoBanAccountAge then
self.ban = true
end
end
if self.ban == true then
self:ban()
end
if Type == "exploit" then
self:sendExploit()
end
return self
end
return log