How could I make this Anti Aimbot work?

this is what the code looks like. It works in studio but it doesn’t detect actuall aimbots.

This specific script only detects aimbots that locks onto a part in workspace. So if u want to try this simply add a part to workspace and name it (“Part”)

local UserInputService = game:GetService("UserInputService")
local runService = game:GetService("RunService")
local player = game:GetService("Players").LocalPlayer
local camera = workspace.CurrentCamera
local part = game:GetService("Workspace").Part

local loop_check = false

UserInputService.InputBegan:Connect(function(Input)
	if Input.UserInputType == Enum.UserInputType.MouseButton2 then	
		loop_check = true 
		while loop_check do
			wait()
			--local delta = UserInputService:GetMouseDelta()
			--print(delta.X, delta.Y)--Attempted to use delta mouse movement didn't work at all
			--camera.CFrame = CFrame.lookAt(game.Players.LocalPlayer.Character.HumanoidRootPart.Position, part.Position) --Uncomment this to turn the aimbot on 
			local lookat = part.Position
			local pos = game.Players.LocalPlayer.Character.HumanoidRootPart.Position
			local cam_check = CFrame.new(lookat, pos)
			if camera.CFrame == cam_check then
				game.Players.LocalPlayer:Kick("Aimbot detected")			
			end
		end
	end
end)

UserInputService.InputEnded:Connect(function(Input)
	if Input.UserInputType == Enum.UserInputType.MouseButton2 then
		loop_check = false
	end
end)

Firstly Decimal Imprecision, The cause of all suffering, Essentially It’s really Hard for two cframe to be exact, Even simple 0.3+0.3 can result in 5.9999999 in roblox, So you should also round them up, Secondly I suggest using Dot product instead of comparing cframe, And thirdly, This script wont work as It’s local sided and exploiter could just stop it’s execution, When I made my anti aimbot I instead focused on reaction time like if its possible that a human click shoot exact as this person goes out of the wall

2 Likes

Thanks for the reply, I’m kind of stupid that i didn’t think of CFrame’s decimals.

Anyways would u say that a one way solution could be to use math.round() wrapped in the
local cam_check