1. local Players = game:GetService("Players")
  2. local CoreGui = game:GetService("CoreGui")
  3.  
  4. local LocalPlayer = Players.LocalPlayer
  5. local LocalDrawingCanvas = nil
  6.  
  7. local BotConfig = {
  8. Enabled = false,
  9. ImageURL = "",
  10. }
  11.  
  12. -- Переменные для библиотек
  13. local Unfilter, BinaryReader, Deflate
  14. local chunks = {}
  15. local PNG = {}
  16. PNG.__index = PNG
  17.  
  18. ---------------------------------------------------------------------------------------------
  19. -- [1. ИНТЕРФЕЙС GUI]
  20. ---------------------------------------------------------------------------------------------
  21. local ScreenGui = Instance.new("ScreenGui")
  22. ScreenGui.Name = "Canvas_CloneTrooper_Safe_v8"
  23. ScreenGui.ResetOnSpawn = false
  24. pcall(function() ScreenGui.Parent = CoreGui end)
  25. if not ScreenGui.Parent then ScreenGui.Parent = LocalPlayer:WaitForChild("PlayerGui") end
  26.  
  27. local MainFrame = Instance.new("Frame")
  28. MainFrame.Size = UDim2.new(0, 250, 0, 300)
  29. MainFrame.Position = UDim2.new(0.05, 0, 0.3, 0)
  30. MainFrame.BackgroundColor3 = Color3.fromRGB(24, 24, 28)
  31. MainFrame.BorderSizePixel = 0
  32. MainFrame.Active = true
  33. MainFrame.Draggable = true
  34. MainFrame.Parent = ScreenGui
  35.  
  36. local UICorner = Instance.new("UICorner")
  37. UICorner.CornerRadius = UDim.new(0, 9)
  38. UICorner.Parent = MainFrame
  39.  
  40. local Title = Instance.new("TextLabel")
  41. Title.Size = UDim2.new(1, 0, 0, 40)
  42. Title.Text = "Бот: Анти-Краш Система"
  43. Title.TextColor3 = Color3.fromRGB(255, 255, 255)
  44. Title.BackgroundColor3 = Color3.fromRGB(34, 34, 40)
  45. Title.Font = Enum.Font.SourceSansBold
  46. Title.TextSize = 14
  47. Title.Parent = MainFrame
  48. local UTCorner = Instance.new("UICorner")
  49. UTCorner.CornerRadius = UDim.new(0, 9)
  50. UTCorner.Parent = Title
  51.  
  52. local function CreateButton(text, yPos, callback)
  53. local Btn = Instance.new("TextButton")
  54. Btn.Size = UDim2.new(1, -20, 0, 35)
  55. Btn.Position = UDim2.new(0, 10, 0, yPos)
  56. Btn.Text = text
  57. Btn.TextColor3 = Color3.fromRGB(240, 240, 240)
  58. Btn.BackgroundColor3 = Color3.fromRGB(44, 44, 52)
  59. Btn.Font = Enum.Font.SourceSansSemibold
  60. Btn.TextSize = 14
  61. Btn.Parent = MainFrame
  62. local c = Instance.new("UICorner")
  63. c.CornerRadius = UDim.new(0, 5)
  64. c.Parent = Btn
  65. Btn.MouseButton1Click:Connect(callback)
  66. return Btn
  67. end
  68.  
  69. local TextBox = Instance.new("TextBox")
  70. TextBox.Size = UDim2.new(1, -20, 0, 30)
  71. TextBox.Position = UDim2.new(0, 10, 0, 135)
  72. TextBox.Text = "Вставь прямую URL ссылку на .png"
  73. TextBox.TextColor3 = Color3.fromRGB(200, 200, 200)
  74. TextBox.BackgroundColor3 = Color3.fromRGB(30, 30, 36)
  75. TextBox.Font = Enum.Font.SourceSans
  76. TextBox.TextSize = 12
  77. TextBox.TextWrapped = true
  78. TextBox.ClearTextOnFocus = false
  79. TextBox.Parent = MainFrame
  80. TextBox.FocusLost:Connect(function(ep) if ep then BotConfig.ImageURL = TextBox.Text end end)
  81.  
  82. local StatusLabel = Instance.new("TextLabel")
  83. StatusLabel.Size = UDim2.new(1, -20, 0, 40)
  84. StatusLabel.Position = UDim2.new(0, 10, 0, 180)
  85. StatusLabel.Text = "Статус: Загрузка библиотек гитхаба..."
  86. StatusLabel.TextColor3 = Color3.fromRGB(255, 165, 0)
  87. StatusLabel.BackgroundTransparency = 1
  88. StatusLabel.TextSize = 13
  89. StatusLabel.TextWrapped = true
  90. StatusLabel.Parent = MainFrame
  91.  
  92. local ProgressBarBg = Instance.new("Frame")
  93. ProgressBarBg.Size = UDim2.new(1, -20, 0, 6)
  94. ProgressBarBg.Position = UDim2.new(0, 10, 0, 275)
  95. ProgressBarBg.BackgroundColor3 = Color3.fromRGB(45, 45, 55)
  96. ProgressBarBg.Parent = MainFrame
  97. local ProgressBarFill = Instance.new("Frame")
  98. ProgressBarFill.Size = UDim2.new(0, 0, 1, 0)
  99. ProgressBarFill.BackgroundColor3 = Color3.fromRGB(0, 255, 150)
  100. ProgressBarFill.BorderSizePixel = 0
  101. ProgressBarFill.Parent = ProgressBarBg
  102.  
  103. local ToggleBtn = CreateButton("ЗАГРУЗКА...", 50, function() end)
  104. ToggleBtn.BackgroundColor3 = Color3.fromRGB(70, 70, 75)
  105. ToggleBtn.AutoButtonColor = false
  106.  
  107. ---------------------------------------------------------------------------------------------
  108. -- [2. ОПТИМИЗИРОВАННЫЕ ФУНКЦИИ PNG ПАРСЕРА]
  109. ---------------------------------------------------------------------------------------------
  110. local function getBytesPerPixel(colorType)
  111. if colorType == 0 or colorType == 3 then return 1
  112. elseif colorType == 4 then return 2
  113. elseif colorType == 2 then return 3
  114. elseif colorType == 6 then return 4
  115. else return 0 end
  116. end
  117.  
  118. local function clampInt(value, min, max)
  119. local num = tonumber(value) or 0
  120. num = math.floor(num + 0.5)
  121. return math.clamp(num, min, max)
  122. end
  123.  
  124. local function indexBitmap(file, x, y)
  125. local width = file.Width
  126. local height = file.Height
  127. x = clampInt(x, 1, width)
  128. y = clampInt(y, 1, height)
  129. local bitmap = file.Bitmap
  130. local bpp = file.BytesPerPixel
  131. local i0 = ((x - 1) * bpp) + 1
  132. local i1 = i0 + bpp
  133. return bitmap[y], i0, i1
  134. end
  135.  
  136. function PNG:GetPixel(x, y)
  137. local row, i0, i1 = indexBitmap(self, x, y)
  138. if not row then return Color3.new(1,1,1), 0 end
  139. local colorType = self.ColorType
  140. local color, alpha
  141.  
  142. if colorType == 0 then
  143. local gray = unpack(row, i0, i1)
  144. color = Color3.fromHSV(0, 0, gray or 0)
  145. alpha = 255
  146. elseif colorType == 2 then
  147. local r, g, b = unpack(row, i0, i1)
  148. color = Color3.fromRGB(r or 0, g or 0, b or 0)
  149. alpha = 255
  150. elseif colorType == 3 then
  151. local palette = self.Palette
  152. local alphaData = self.AlphaData
  153. local index = unpack(row, i0, i1)
  154. index = (index or 0) + 1
  155. if palette then color = palette[index] end
  156. if alphaData then alpha = alphaData[index] end
  157. elseif colorType == 4 then
  158. local gray, a = unpack(row, i0, i1)
  159. color = Color3.fromHSV(0, 0, gray or 0)
  160. alpha = a
  161. elseif colorType == 6 then
  162. local r, g, b, a = unpack(row, i0, i1)
  163. color = Color3.fromRGB(r or 0, g or 0, b or 0)
  164. alpha = a
  165. end
  166.  
  167. if not color then color = Color3.new(1, 1, 1) end
  168. if not alpha then alpha = 255 end
  169. return color, alpha
  170. end
  171.  
  172. function PNG.new(buffer)
  173. local reader = BinaryReader.new(buffer)
  174. local file = { Chunks = {}, Metadata = {}, Reading = true, ZlibStream = "" }
  175. local header = reader:ReadString(8)
  176. if header ~= "\137PNG\r\n\26\n" then error("PNG - Input data is not a PNG file.", 2) end
  177.  
  178. while file.Reading do
  179. local length = reader:ReadInt32()
  180. local chunkType = reader:ReadString(4)
  181. local data, crc
  182. if length > 0 then
  183. data = reader:ForkReader(length)
  184. crc = reader:ReadUInt32()
  185. end
  186. local chunk = { Length = length, Type = chunkType, Data = data, CRC = crc }
  187. local handler = chunks[chunkType]
  188. if handler then handler(file, chunk) end
  189. table.insert(file.Chunks, chunk)
  190. end
  191.  
  192. -- АНТИ-КРАШ МОДИФИКАЦИЯ РАСПАКОВКИ ИНФЛЕЙТА
  193. local success, response = pcall(function()
  194. local result = {}
  195. local index = 0
  196.  
  197. Deflate:InflateZlib({
  198. Input = BinaryReader.new(file.ZlibStream),
  199. Output = function(byte)
  200. index = index + 1
  201. result[index] = string.char(byte)
  202.  
  203. -- Каждые 40000 распакованных байт даем движку Roblox вздохнуть
  204. if index % 40000 == 0 then
  205. task.wait()
  206. end
  207. end
  208. })
  209. return table.concat(result)
  210. end)
  211.  
  212. if not success then error("PNG - Unable to unpack PNG data. " .. tostring(response), 2) end
  213.  
  214. local width = file.Width
  215. local height = file.Height
  216. local bitDepth = file.BitDepth
  217. local colorType = file.ColorType
  218. local buffer = BinaryReader.new(response)
  219. file.ZlibStream = nil
  220. local bitmap = {}
  221. file.Bitmap = bitmap
  222. local channels = getBytesPerPixel(colorType)
  223. file.NumChannels = channels
  224. local bpp = math.max(1, channels * (bitDepth / 8))
  225. file.BytesPerPixel = bpp
  226.  
  227. for row = 1, height do
  228. -- Плавное чтение строк развертки
  229. if row % 2 == 0 then task.wait() end
  230. local filterType = buffer:ReadByte()
  231. local scanline = buffer:ReadBytes(width * bpp, true)
  232. bitmap[row] = {}
  233.  
  234. if filterType == 0 then Unfilter:None(scanline, bitmap, bpp, row)
  235. elseif filterType == 1 then Unfilter:Sub(scanline, bitmap, bpp, row)
  236. elseif filterType == 2 then Unfilter:Up(scanline, bitmap, bpp, row)
  237. elseif filterType == 3 then Unfilter:Average(scanline, bitmap, bpp, row)
  238. elseif filterType == 4 then Unfilter:Paeth(scanline, bitmap, bpp, row) end
  239. end
  240. return setmetatable(file, PNG)
  241. end
  242.  
  243. ---------------------------------------------------------------------------------------------
  244. -- [3. АСИНХРОННОЕ СКАЧИВАНИЕ МОДУЛЕЙ]
  245. ---------------------------------------------------------------------------------------------
  246. task.spawn(function()
  247. getfenv().bit32 = bit
  248.  
  249. local function secureGet(url)
  250. local s, r = pcall(function() return game:HttpGet(url) end)
  251. if s then return loadstring(r)() else return nil end
  252. end
  253.  
  254.  
  255.  
  256. if Unfilter and BinaryReader and Deflate and chunks.IDAT and chunks.IHDR then
  257. StatusLabel.Text = "Статус: Модули активны! Готов рисовать."
  258. StatusLabel.TextColor3 = Color3.fromRGB(0, 200, 100)
  259. ToggleBtn.Text = "СТАРТ"
  260. ToggleBtn.BackgroundColor3 = Color3.fromRGB(40, 150, 80)
  261. ToggleBtn.AutoButtonColor = true
  262. else
  263. StatusLabel.Text = "Ошибка: Сбой загрузки гитхаба!"
  264. StatusLabel.TextColor3 = Color3.fromRGB(255, 50, 50)
  265. ToggleBtn.Text = "ОШИБКА СЕТИ"
  266. end
  267. end)
  268.  
  269. ---------------------------------------------------------------------------------------------
  270. -- [4. ПОИСК МОЛЬБЕРТА И ПРОВЕРКА]
  271. ---------------------------------------------------------------------------------------------
  272. local function FindLocalDrawingCanvas()
  273. local playerGui = LocalPlayer:FindFirstChild("PlayerGui")
  274. if not playerGui then return nil end
  275. local canvasFrame = nil
  276. for _, v in ipairs(playerGui:GetDescendants()) do
  277. if v:IsA("Frame") and v:FindFirstChild("FastCanvas") then canvasFrame = v break end
  278. end
  279. if not canvasFrame then return nil end
  280.  
  281. local successGC, registry = pcall(getgc, true)
  282. if successGC then
  283. for i = 1, #registry do
  284. local obj = registry[i]
  285. if type(obj) == "table" and rawget(obj, "DrawLine") then
  286. if rawget(obj, "CurrentCanvasFrame") == canvasFrame or tostring(rawget(obj, "CurrentCanvasFrame")) == tostring(canvasFrame) then
  287. return obj
  288. end
  289. end
  290. end
  291. end
  292. return nil
  293. end
  294.  
  295. CreateButton("Залить холст (проверка)", 90, function()
  296. LocalDrawingCanvas = FindLocalDrawingCanvas()
  297. if LocalDrawingCanvas then
  298. local randomColor = Color3.fromRGB(math.random(0,255), math.random(0,255), math.random(0,255))
  299. if LocalDrawingCanvas.Fill then
  300. LocalDrawingCanvas:Fill(randomColor)
  301. else
  302. local resX = LocalDrawingCanvas.CurrentResX or 150
  303. local resY = LocalDrawingCanvas.CurrentResY or 150
  304. LocalDrawingCanvas:DrawLine(Vector2.new(1,1), Vector2.new(resX, resY), randomColor, resX)
  305. end
  306. if LocalDrawingCanvas.Render then LocalDrawingCanvas:Render() end
  307. end
  308. end)
  309.  
  310. local drawingThread = nil
  311.  
  312. ToggleBtn.MouseButton1Click:Connect(function()
  313. if not Deflate then return end
  314.  
  315. if BotConfig.Enabled then
  316. BotConfig.Enabled = false
  317. ToggleBtn.Text = "СТАРТ"
  318. ToggleBtn.BackgroundColor3 = Color3.fromRGB(40, 150, 80)
  319. if drawingThread then task.cancel(drawingThread) end
  320. StatusLabel.Text = "Остановлено."
  321. ProgressBarFill.Size = UDim2.new(0, 0, 1, 0)
  322. else
  323. LocalDrawingCanvas = FindLocalDrawingCanvas()
  324. if not LocalDrawingCanvas then StatusLabel.Text = "Ошибка: Открой мольберт!" return end
  325. if BotConfig.ImageURL == "" or not string.match(BotConfig.ImageURL, "http") then StatusLabel.Text = "Ошибка: Нет рабочей URL ссылки!" return end
  326.  
  327. BotConfig.Enabled = true
  328. ToggleBtn.Text = "ОСТАНОВИТЬ"
  329. ToggleBtn.BackgroundColor3 = Color3.fromRGB(170, 40, 40)
  330.  
  331. drawingThread = task.spawn(function()
  332. StatusLabel.Text = "Скачивание .png..."
  333. local successFetch, resultBuffer = pcall(function() return game:HttpGet(BotConfig.ImageURL) end)
  334. if not successFetch then StatusLabel.Text = "Ошибка HTTP загрузки файла!" BotConfig.Enabled = false ToggleBtn.Text = "СТАРТ" return end
  335.  
  336. StatusLabel.Text = "Распаковка PNG (Защита от лагов)..."
  337. task.wait() -- Даем кадр перед тяжелым парсингом
  338.  
  339. local successPng, pngImage = pcall(function() return PNG.new(resultBuffer) end)
  340. if not successPng or not pngImage then
  341. StatusLabel.Text = "Ошибка декомпрессии файла! Файл слишком большой или поврежден."
  342. BotConfig.Enabled = false ToggleBtn.Text = "СТАРТ" return
  343. end
  344.  
  345. local resX = tonumber(LocalDrawingCanvas.CurrentResX or 150)
  346. local resY = tonumber(LocalDrawingCanvas.CurrentResY or 150)
  347.  
  348. StatusLabel.Text = "Отрисовка на холст..."
  349.  
  350. for y = 1, resY do
  351. if not BotConfig.Enabled then return end
  352.  
  353. for x = 1, resX do
  354. local srcX = math.clamp(math.floor((x / resX) * pngImage.Width), 1, pngImage.Width)
  355. local srcY = math.clamp(math.floor((y / resY) * pngImage.Height), 1, pngImage.Height)
  356.  
  357. local color, alpha = pngImage:GetPixel(srcX, srcY)
  358.  
  359. if alpha > 15 then
  360. local pPos = Vector2.new(x, y)
  361. LocalDrawingCanvas:DrawLine(pPos, pPos, color, 1)
  362. end
  363. end
  364.  
  365. ProgressBarFill.Size = UDim2.new(y / resY, 0, 1, 0)
  366.  
  367. if y % 3 == 0 then
  368. if LocalDrawingCanvas.Render then LocalDrawingCanvas:Render() end
  369. task.wait()
  370. end
  371. end
  372.  
  373. if LocalDrawingCanvas.Render then LocalDrawingCanvas:Render() end
  374. StatusLabel.Text = "Готово!"
  375. BotConfig.Enabled = false
  376. ToggleBtn.Text = "СТАРТ"
  377. ToggleBtn.BackgroundColor3 = Color3.fromRGB(40, 150, 80)
  378. end)
  379. end
  380. end)