Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- janus, note the aimBot is toggle not hold.
- -- Config --
- local toggleAimBotKey = Enum.KeyCode.E
- -- End of Config --
- local userInputService = game:GetService("UserInputService")
- local player = game.Players.LocalPlayer
- local runService = game:GetService("RunService")
- local players = {}
- local aimBotEnabled = false
- local Camera = game.Workspace.CurrentCamera
- local connection = nil
- local aimBotTarget = nil
- local mouse = player:GetMouse()
- local function getTargetPlayer()
- local smallestMag = 9999
- local closestPlayer
- local mousePos = Vector2.new(userInputService:GetMouseLocation().x, userInputService:GetMouseLocation().y)
- for i,v in pairs(game.Players:GetPlayers()) do
- if (v ~= player) then
- if (v.Character ~= nil) then
- if (v.Character:FindFirstChild("Humanoid") ~= nil) then
- if (v.Character:FindFirstChild("Humanoid").Health ~= 0) then
- local targetPlayerPos = Camera:WorldToScreenPoint(v.Character:WaitForChild("HumanoidRootPart", math.huge).Position)
- if (targetPlayerPos.Z > 0) then
- local targetPlayerVec2 = Vector2.new(targetPlayerPos.X, targetPlayerPos.Y)
- local mag = (targetPlayerVec2 - mousePos).Magnitude
- if (mag < smallestMag) then
- smallestMag = mag
- closestPlayer = v
- end
- end
- else
- Camera.CameraType = Enum.CameraType.Custom
- Camera.CameraType = Enum.CameraType.Scriptable
- end
- end
- end
- end
- end
- aimBotTarget = closestPlayer.Character:FindFirstChild("Head")
- end
- userInputService.InputBegan:Connect(function(inputObject)
- if (inputObject.KeyCode == toggleAimBotKey) then
- if (aimBotEnabled) then
- aimBotEnabled = false
- hasTarget = false
- Camera.CameraType = Enum.CameraType.Custom
- else
- aimBotEnabled = true
- Camera.CameraType = Enum.CameraType.Scriptable
- end
- end
- end)
- connection = runService.Heartbeat:Connect(function()
- if (aimBotEnabled) then
- getTargetPlayer()
- if (aimBotTarget ~= nil) then
- Camera.CameraType = Enum.CameraType.Scriptable
- Camera.CFrame = CFrame.new(player.Character.Head.Position, aimBotTarget.position)
- else
- hasTarget = false
- Camera.CameraType = Enum.CameraType.Custom
- end
- end
- if (player.Character:FindFirstChild("Humanoid").Health == 0) then
- aimBotEnabled = false
- hasTarget = false
- Camera.CameraType = Enum.CameraType.Custom
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment