Quick actions

cmd+k|ctrl+k

Navigation

Languages

Lidar

Snippet info

Language

Lua

Visibility

public

Author

shashlik

Created

2025-07-11T23:30:40.892627Z

Updated

2025-07-11T23:33:02.476635Z

local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera


local crosshairSettings = {
    color = Color3.fromRGB(255, 255/2, 255),    -- Цвет прицела
    thickness = 2,                              -- Толщина линий в пикселях
    length = 8,                                 -- Длина линий в пикселях
    opacity = 1,                                -- Прозрачность (1 - полностью видимый)
    x_offset = 0,                               -- Смещение по X
    y_offset = 0,                               -- Смещение по Y
    recenter = true                             -- Автоматическое центрирование
}

local PIXEL_SIZE = 0.5
local PIXEL_COLOR = Color3.fromRGB(255, 255, 255)
local MAX_DISTANCE = 1000
local PIXELS_PER_TICK = 30
local PIXEL_LIFETIME = 240
local MAX_PIXELS = 50000
local SPREAD_ANGLE = 5

local tool = Instance.new("Tool")
tool.Name = "Lidar (Laggy)"
tool.RequiresHandle = false
tool.Parent = player.Backpack

player.CharacterAdded:Connect(function()
    tool.Parent = player.Backpack
end)

local handle = Instance.new("Part")
handle.Name = "Handle"
handle.Size = Vector3.new(0.2, 0.2, 0.2)
handle.Transparency = 1
handle.CanCollide = false
handle.Anchored = false
handle.Parent = tool

local function createPixel(position, normal)
    local pixel = Instance.new("Part")
    pixel.Name = "WhitePixel"
    pixel.Size = Vector3.new(PIXEL_SIZE, PIXEL_SIZE, PIXEL_SIZE)
    pixel.Color = PIXEL_COLOR
    pixel.Material = Enum.Material.Neon
    pixel.Anchored = true
    pixel.CanCollide = false
    pixel.Transparency = 0.3

    pixel.CFrame = CFrame.new(position, position + normal)

    local billboard = Instance.new("BillboardGui")
    billboard.Size = UDim2.new(0.2, 0, 0.2, 0)
    billboard.MaxDistance = MAX_DISTANCE
    billboard.AlwaysOnTop = true
    billboard.Parent = pixel

    local frame = Instance.new("Frame")
    frame.Size = UDim2.new(1, 0, 1, 0)
    frame.BackgroundColor3 = PIXEL_COLOR
    frame.BackgroundTransparency = 0.3
    frame.BorderSizePixel = 0
    frame.Parent = billboard

    pixel.Parent = workspace
    return pixel
end

local function createDrawingCrosshair()
    getgenv().crosshair_x = getgenv().crosshair_x or {}
    getgenv().crosshair_y = getgenv().crosshair_y or {}

    if getgenv().crosshair_x["Line"] then
        getgenv().crosshair_x["Line"]:Remove()
    end
    
    if getgenv().crosshair_x["Connection"] then
        getgenv().crosshair_x["Connection"]:Disconnect()
    end

    if getgenv().crosshair_y["Line"] then
        getgenv().crosshair_y["Line"]:Remove()
    end

    if getgenv().crosshair_y["Connection"] then
        getgenv().crosshair_y["Connection"]:Disconnect()
    end

    local function drawLine(type, properties)
        local obj = Drawing.new(type)
        for prop, value in pairs(properties) do
            obj[prop] = value
        end
        return obj
    end

    getgenv().crosshair_x["Line"] = drawLine("Line", {
        To = Vector2.new(((camera.ViewportSize.X / 2) - crosshairSettings.x_offset) - crosshairSettings.length, 
                        (camera.ViewportSize.Y / 2) - crosshairSettings.y_offset),
        From = Vector2.new(((camera.ViewportSize.X / 2) - crosshairSettings.x_offset) + crosshairSettings.length, 
                          (camera.ViewportSize.Y / 2) - crosshairSettings.y_offset),
        Thickness = crosshairSettings.thickness,
        Color = crosshairSettings.color,
        Transparency = 1 - crosshairSettings.opacity,
        Visible = true
    })

    getgenv().crosshair_y["Line"] = drawLine("Line", {
        To = Vector2.new((camera.ViewportSize.X / 2) - crosshairSettings.x_offset, 
                        ((camera.ViewportSize.Y / 2) - crosshairSettings.y_offset) - crosshairSettings.length),
        From = Vector2.new((camera.ViewportSize.X / 2) - crosshairSettings.x_offset, 
                          ((camera.ViewportSize.Y / 2) - crosshairSettings.y_offset) + crosshairSettings.length),
        Thickness = crosshairSettings.thickness,
        Color = crosshairSettings.color,
        Transparency = 1 - crosshairSettings.opacity,
        Visible = true
    })

    if crosshairSettings.recenter then
        getgenv().crosshair_x["Connection"] = camera:GetPropertyChangedSignal("ViewportSize"):Connect(function()
            getgenv().crosshair_x["Line"].To = Vector2.new(((camera.ViewportSize.X / 2) - crosshairSettings.x_offset) - crosshairSettings.length, 
                                              (camera.ViewportSize.Y / 2) - crosshairSettings.y_offset)
            getgenv().crosshair_x["Line"].From = Vector2.new(((camera.ViewportSize.X / 2) - crosshairSettings.x_offset) + crosshairSettings.length, 
                                                (camera.ViewportSize.Y / 2) - crosshairSettings.y_offset)
        end)

        getgenv().crosshair_y["Connection"] = camera:GetPropertyChangedSignal("ViewportSize"):Connect(function()
            getgenv().crosshair_y["Line"].To = Vector2.new((camera.ViewportSize.X / 2) - crosshairSettings.x_offset, 
                                              ((camera.ViewportSize.Y / 2) - crosshairSettings.y_offset) - crosshairSettings.length)
            getgenv().crosshair_y["Line"].From = Vector2.new((camera.ViewportSize.X / 2) - crosshairSettings.x_offset, 
                                                ((camera.ViewportSize.Y / 2) - crosshairSettings.y_offset) + crosshairSettings.length)
        end)
    end
end

local active = false
local heartbeatConnection
local pixels = {}

tool.Equipped:Connect(function()
    active = true
    createDrawingCrosshair()
    
    heartbeatConnection = game:GetService("RunService").Heartbeat:Connect(function()
        if not active then return end
        
        local lookDirection = camera.CFrame.LookVector
        
        local raycastParams = RaycastParams.new()
        raycastParams.FilterDescendantsInstances = {tool, player.Character}
        raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
        
        local centerResult = workspace:Raycast(camera.CFrame.Position, lookDirection * MAX_DISTANCE, raycastParams)
        if centerResult and centerResult.Instance.CanCollide then
            createPixel(centerResult.Position, centerResult.Normal)
        end
        
        for _ = 1, PIXELS_PER_TICK - 1 do
            local spreadAngleRad = math.rad(math.random(-SPREAD_ANGLE, SPREAD_ANGLE))
            local spreadAngleRad2 = math.rad(math.random(-SPREAD_ANGLE, SPREAD_ANGLE))
            local spreadDirection = (CFrame.new(Vector3.new(0, 0, 0), lookDirection) * CFrame.Angles(spreadAngleRad, spreadAngleRad2, 0)).LookVector

            local result = workspace:Raycast(camera.CFrame.Position, spreadDirection * MAX_DISTANCE, raycastParams)

            if result and result.Instance.CanCollide then
                createPixel(result.Position, result.Normal)
            end
        end
    end)
end)

tool.Unequipped:Connect(function()
    active = false
    if getgenv().crosshair_x and getgenv().crosshair_x["Line"] then
        getgenv().crosshair_x["Line"].Visible = false
    end
    if getgenv().crosshair_y and getgenv().crosshair_y["Line"] then
        getgenv().crosshair_y["Line"].Visible = false
    end
    if heartbeatConnection then
        heartbeatConnection:Disconnect()
        heartbeatConnection = nil
    end
end)

game:GetService("RunService").Heartbeat:Connect(function()
    local currentTime = tick()
    for i = #pixels, 1, -1 do
        local pixelData = pixels[i]
        if pixelData and pixelData.Pixel and pixelData.Pixel.Parent then
            local pixel = pixelData.Pixel
            if currentTime - pixelData.CreatedTime >= PIXEL_LIFETIME then
                local hrp = player.Character and player.Character:FindFirstChild("HumanoidRootPart")
                if hrp then
                    local viewAngle = (pixel.Position - hrp.Position).Unit:Dot(hrp.CFrame.LookVector)
                    if viewAngle <= 0 then
                        pixel:Destroy()
                        table.remove(pixels, i)
                    end
                end
            end
        else
            table.remove(pixels, i)
        end
    end

    while #pixels > MAX_PIXELS do
        local pixelData = pixels[1]
        if pixelData and pixelData.Pixel then
            pixelData.Pixel:Destroy()
        end
        table.remove(pixels, 1)
    end
end)

local oldCreatePixel = createPixel
createPixel = function(position, normal)
    local pixel = oldCreatePixel(position, normal)
    table.insert(pixels, {
        Pixel = pixel,
        CreatedTime = tick()
    })
    return pixel
end
INFO