Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local RunService = game:GetService("RunService")
- local UserInputService = game:GetService("UserInputService")
- local GuiService = game:GetService("GuiService")
- local Workspace = game:GetService("Workspace")
- -- Configuration
- local MAX_DISTANCE = 2500 -- Maximum distance to show ESP
- local HEALTH_BAR_WIDTH = 50
- local HEALTH_BAR_HEIGHT = 5
- local AIM_LOCK_KEY = Enum.KeyCode.E
- -- Anti-Cheat Mitigation
- local AIM_SMOOTHNESS = 0.3 -- Lower is smoother, less suspicious
- local MIN_AIM_DISTANCE = 10 -- Minimum distance to start aiming
- local MAX_AIM_DISTANCE = 500 -- Maximum aim distance
- -- Settings (will be controlled by GUI)
- local Settings = {
- ESPEnabled = true,
- AimLockEnabled = false
- }
- -- Utility function to check line of sight
- local function isVisible(origin, target)
- local viewCheck = workspace:FindPartOnRayWithIgnoreList(
- Ray.new(origin, target - origin),
- {Players.LocalPlayer.Character}
- )
- return viewCheck == nil
- end
- -- Create main ScreenGui
- local mainGui = Instance.new("ScreenGui")
- mainGui.Name = "HackToolGui"
- mainGui.Parent = Players.LocalPlayer:WaitForChild("PlayerGui")
- -- Create Toggle GUI (Previous GUI code remains the same)
- -- ... [GUI creation code from previous script] ...
- -- Create ScreenGui to hold ESP elements
- local espGui = Instance.new("ScreenGui")
- espGui.Name = "ESPGui"
- espGui.Parent = Players.LocalPlayer:WaitForChild("PlayerGui")
- -- Table to store ESP elements
- local espElements = {}
- -- Function to create ESP for a player (Previous implementation)
- local function createESP(player)
- if player == Players.LocalPlayer then return end
- local nameLabel = Drawing.new("Text")
- nameLabel.Font = Drawing.Fonts.UI
- nameLabel.Size = 13
- nameLabel.Center = true
- nameLabel.Outline = true
- local healthBarBackground = Drawing.new("Rectangle")
- healthBarBackground.Filled = true
- healthBarBackground.Color = Color3.new(0, 0, 0)
- healthBarBackground.Transparency = 0.5
- local healthBarForeground = Drawing.new("Rectangle")
- healthBarForeground.Filled = true
- healthBarForeground.Color = Color3.new(0, 1, 0)
- espElements[player] = {
- nameLabel = nameLabel,
- healthBarBackground = healthBarBackground,
- healthBarForeground = healthBarForeground
- }
- end
- -- Function to update ESP for a player (with minor modifications)
- local function updateESP(player, espData)
- -- Skip if ESP is disabled
- if not Settings.ESPEnabled then
- espData.nameLabel.Visible = false
- espData.healthBarBackground.Visible = false
- espData.healthBarForeground.Visible = false
- return
- end
- local character = player.Character
- local humanoid = character and character:FindFirstChildOfClass("Humanoid")
- local root = character and character:FindFirstChild("HumanoidRootPart")
- if not character or not humanoid or not root then
- espData.nameLabel.Visible = false
- espData.healthBarBackground.Visible = false
- espData.healthBarForeground.Visible = false
- return
- end
- local screenPos, onScreen = Workspace.CurrentCamera:WorldToViewportPoint(root.Position)
- local localPlayerRoot = Players.LocalPlayer.Character and Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart")
- local distance = localPlayerRoot and (root.Position - localPlayerRoot.Position).Magnitude or math.huge
- if not onScreen or distance > MAX_DISTANCE then
- espData.nameLabel.Visible = false
- espData.healthBarBackground.Visible = false
- espData.healthBarForeground.Visible = false
- return
- end
- local teamColor = player.TeamColor or Color3.new(1, 1, 1)
- espData.nameLabel.Position = Vector2.new(screenPos.X, screenPos.Y - 20)
- espData.nameLabel.Text = player.Name
- espData.nameLabel.Color = teamColor.Color
- espData.nameLabel.Visible = true
- local healthPercentage = humanoid.Health / humanoid.MaxHealth
- espData.healthBarBackground.Position = Vector2.new(screenPos.X - HEALTH_BAR_WIDTH/2, screenPos.Y + 10)
- espData.healthBarBackground.Size = Vector2.new(HEALTH_BAR_WIDTH, HEALTH_BAR_HEIGHT)
- espData.healthBarBackground.Visible = true
- espData.healthBarForeground.Position = Vector2.new(screenPos.X - HEALTH_BAR_WIDTH/2, screenPos.Y + 10)
- espData.healthBarForeground.Size = Vector2.new(HEALTH_BAR_WIDTH * healthPercentage, HEALTH_BAR_HEIGHT)
- espData.healthBarForeground.Color = Color3.fromRGB(255 * (1 - healthPercentage), 255 * healthPercentage, 0)
- espData.healthBarForeground.Visible = true
- end
- -- Improved Aim Lock Function
- local function findNearestPlayerToCrosshair()
- local localPlayer = Players.LocalPlayer
- local camera = Workspace.CurrentCamera
- local localCharacter = localPlayer.Character
- if not localCharacter then return nil end
- local nearestPlayer = nil
- local shortestDistance = math.huge
- for _, player in ipairs(Players:GetPlayers()) do
- -- Skip self, teammates, and players without character
- if player ~= localPlayer and
- player.Team ~= localPlayer.Team and
- player.Character and
- player.Character:FindFirstChild("Head") then
- local headPos = player.Character.Head.Position
- local screenPos, onScreen = camera:WorldToScreenPoint(headPos)
- if onScreen then
- -- Calculate distance from screen center
- local distance = (Vector2.new(screenPos.X, screenPos.Y) -
- Vector2.new(camera.ViewportSize.X/2, camera.ViewportSize.Y/2)).Magnitude
- -- Additional checks for aim lock
- local rootPart = player.Character:FindFirstChild("HumanoidRootPart")
- local distanceToPlayer = (rootPart.Position - localCharacter.HumanoidRootPart.Position).Magnitude
- if distance < shortestDistance and
- distanceToPlayer >= MIN_AIM_DISTANCE and
- distanceToPlayer <= MAX_AIM_DISTANCE and
- isVisible(localCharacter.Head.Position, headPos) then
- nearestPlayer = player
- shortestDistance = distance
- end
- end
- end
- end
- return nearestPlayer
- end
- -- Aim Lock Logic
- RunService.Heartbeat:Connect(function()
- -- Update ESP for all players
- for player, espData in pairs(espElements) do
- updateESP(player, espData)
- end
- -- Aim Lock Logic
- if Settings.AimLockEnabled then
- local nearestPlayer = findNearestPlayerToCrosshair()
- if nearestPlayer and nearestPlayer.Character and nearestPlayer.Character:FindFirstChild("Head") then
- local camera = Workspace.CurrentCamera
- local targetHead = nearestPlayer.Character.Head
- -- Smooth aim lock with interpolation
- local currentCFrame = camera.CFrame
- local targetCFrame = CFrame.new(currentCFrame.Position, targetHead.Position)
- camera.CFrame = currentCFrame:Lerp(targetCFrame, AIM_SMOOTHNESS)
- end
- end
- end)
- -- Rest of the script remains the same (Player added/removed events, cleanup, etc.)
- -- ... [Previous initialization and cleanup code]
- -- Additional safety measure
- if not game:GetService("RunService"):IsStudio() then
- delay(math.random(60, 180), function()
- script:Destroy()
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement