Detecting Aimbot

Name
Hi my name is Baccon!

What am i trying to do
So, I was sent this script and it’s an aimbot script… i need some tips on how i would be able to prevent this script.

Script

local players = game:GetService("Players")
local uis = game:GetService("UserInputService")

local player = players.LocalPlayer

local UI = Instance.new("ScreenGui")
local Destruct = Instance.new("TextButton")
local Notify = Instance.new("TextLabel")

UI.Name = "UI"
UI.Parent = game.CoreGui

Destruct.Name = "Destruct"
Destruct.Parent = UI
Destruct.BackgroundColor3 = Color3.new(1, 1, 1)
Destruct.BorderSizePixel = 0
Destruct.Position = UDim2.new(0.864374995, 0, 0.254732537, 0)
Destruct.Size = UDim2.new(0.125, 0, 0.035665296, 0)
Destruct.Font = Enum.Font.GothamBlack
Destruct.Text = "Self Destruct UI"
Destruct.TextColor3 = Color3.new(0, 0, 0)
Destruct.TextSize = 14

Notify.Name = "Notify"
Notify.Parent = UI
Notify.BackgroundColor3 = Color3.new(1, 1, 1)
Notify.BorderSizePixel = 0
Notify.Position = UDim2.new(0.864374995, 0, 0.202606308, 0)
Notify.Size = UDim2.new(0.125, 0, 0.0260630995, 0)
Notify.Font = Enum.Font.SourceSans
Notify.Text = "It is on."
Notify.TextColor3 = Color3.new(0, 0, 0)
Notify.TextSize = 14

local meta = getrawmetatable(game)
local old = meta.__namecall
setreadonly(meta, false)

local goals = {}

local shotkey = Enum.KeyCode.X
local toggle = true

do
	for i, v in pairs(workspace:GetDescendants()) do 
		--[ CHECK ]--
		if (v:FindFirstChild("Anti Aimbot") and v:IsA("BasePart")) then 
			table.insert(goals, v)
		end
	end
end

--[ LOCAL_FUNCTIONS ]--
local function Check(mag)
	--[ CHECK_MAGNITUDE ]--
    if (mag > 100) then 
        return 100 
    else
        return mag
    end
end

local function Distance(obj1, obj2)
    return (obj1.Position - obj2.Position).magnitude
end

local function GetClosest(root)
    local distances = {}
    
    for _, v in pairs(goals) do
        table.insert(distances, Distance(root,v))
    end
    
    local closest = math.min(unpack(distances))
    
    for _, v in pairs(goals) do
        local distance = Distance(root, v)

        if (distance == closest) then
            return v
        end
    end
end

Destruct.MouseButton1Click:Connect(function()
	toggle = false
	UI:Destroy()
end)

uis.InputBegan:Connect(function(key, gpe)
	if (gpe) then
		return
	end
	
	if (key.KeyCode == shotkey) then
		toggle = not toggle
		
		if (UI and Notify) then
			Notify.Text = "It is " .. (toggle and "on" or "off") .. "."
		end
	end
end)

meta.__namecall = newcclosure(function(self, ...)
    local method = getnamecallmethod()
    local args = {...}

    if (method == "FireServer" and self.Name == "BallRemote") then
		if (typeof(args[1]) == "Vector3" and toggle) then
			local character = player.Character
			local root = character.HumanoidRootPart
			local goal = GetClosest(root)
			local disp = (character.Torso.Position - goal.Position)
        	local mag = disp.magnitude
			
			--[ SET ]--
			args[1] = (goal.CFrame * CFrame.new(0, 0, 0)).Position + Vector3.new(0, (mag * 0.90), 0)
			
			return old(self, unpack(args))
		end
    end

    return old(self, unpack(args))
end)

setreadonly(meta, true)
1 Like

Hey @QWithABaccon

You could start by detecting if anything is added to the game.CoreGui and destroy it.

game.CoreGui.ChildAdded:Connect(function(child)
	-- Destroy the child
	if child.Name == UI and child:IsA("ScreenGui") then
child:Destory()
end)

There are more other ways but that is one of them. :+1:

You can’t access CoreGui but only the defined users can. You can’t detect aimbot but you can decrease the usage of it. You can calculate the camera speed in a second or if there are more than 5 headshots – or some number else – you can record it as a doubt.

1 Like

ok, so when you say that just defined users can access the CoreGui, then his aimbot script doesn’t work?

Before this, you can research about the CoreGui.

Somehow the exploit scripts force the core gui to take the script. But the script you use won’t be detecting the children of the core gui even the events fired.

There is only one way to use core gui I assume

game:GetService("CoreGui") 

No script is allowed except for some properties.

1 Like

It is because of ContextSecurityLevel. Regular local scripts are like level 0 or 1, exploits are like a 7.

Mainly because exploits just inject bytecode, you could probably instead just put a votekick system, so that way the players can deal with it.

One way you can try to prevent aimbot is to check how far a camera has moved and check how long it took them to go to it with tick().

1 Like