Nevzyn

Untitled

Nov 17th, 2025
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.57 KB | None | 0 0
  1. --[[
  2. =================================================================================================
  3. -- || SCRIPT: Auto Block System v2 (Otimizado para Mobile/Delta) ||
  4. -- || DESCRIÇÃO: Versão aprimorada com UI estável (Orion Library) para executores mobile. ||
  5. -- || - Interface simples, arrastável e minimizável por padrão. ||
  6. -- || - Coleta automática de blocos com teleporte de ida e volta. ||
  7. -- || - Equipa o bloco automaticamente após a coleta. ||
  8. -- || - Lógica aprimorada para encontrar a pilha de blocos sem precisar de nomes. ||
  9. =================================================================================================
  10. --]]
  11.  
  12. -- Carrega a biblioteca de UI Orion, que é muito estável em executores mobile
  13. local OrionLib = loadstring(game:HttpGet(('https://raw.githubusercontent.com/shlexware/Orion/main/source')))()
  14.  
  15. --=================================================================================================
  16. -- >> CONFIGURAÇÕES <<
  17. -- Altere aqui se necessário.
  18. --=================================================================================================
  19. local CONFIG = {
  20. -- Nomes EXATOS das ferramentas de bloco no seu inventário (Backpack).
  21. -- Adicione mais nomes se houver. É importante que pelo menos um desses nomes corresponda.
  22. BLOCK_TOOL_NAMES = {
  23. "Block", "Bloco", "Red Block", "Blue Block", "Green Block", "Yellow Block"
  24. },
  25.  
  26. -- Palavras-chave para ajudar o script a encontrar o gerador de blocos do seu time.
  27. -- O script já procura por geradores com a cor do seu time.
  28. PILE_KEYWORDS = {
  29. "generator", "gerador", "spawn", "pile", "coleta"
  30. },
  31.  
  32. -- Tempo máximo (em segundos) para esperar por um bloco antes de voltar. Evita ficar preso.
  33. TELEPORT_TIMEOUT = 4,
  34. }
  35.  
  36. --=================================================================================================
  37. -- >> SERVIÇOS E VARIÁVEIS GLOBAIS <<
  38. --=================================================================================================
  39. local RunService = game:GetService("RunService")
  40. local Players = game:GetService("Players")
  41.  
  42. local LocalPlayer = Players.LocalPlayer
  43.  
  44. local isTeleporting = false
  45. local previousCFrame = nil
  46. local blockPilePosition = nil
  47. local isSystemEnabled = false
  48.  
  49. --=================================================================================================
  50. -- >> FUNÇÕES DO NÚCLEO (LÓGICA PRINCIPAL) <<
  51. --=================================================================================================
  52.  
  53. -- Conta quantos blocos o jogador possui no inventário ou na mão.
  54. function getInventoryBlockCount()
  55. local count = 0
  56. local backpack = LocalPlayer.Backpack
  57. local character = LocalPlayer.Character
  58.  
  59. for _, tool in ipairs(backpack:GetChildren()) do
  60. if tool:IsA("Tool") and table.find(CONFIG.BLOCK_TOOL_NAMES, tool.Name) then
  61. count = count + 1
  62. end
  63. end
  64.  
  65. if character and character:FindFirstChildOfClass("Tool") and table.find(CONFIG.BLOCK_TOOL_NAMES, character:FindFirstChildOfClass("Tool").Name) then
  66. count = count + 1
  67. end
  68.  
  69. return count
  70. end
  71.  
  72. -- Encontra a pilha de blocos de forma inteligente (essencial para mobile)
  73. function findBlockPile()
  74. local character = LocalPlayer.Character
  75. local rootPart = character and character:FindFirstChild("HumanoidRootPart")
  76. local playerTeam = LocalPlayer.Team
  77.  
  78. if not rootPart or not playerTeam then
  79. OrionLib:MakeNotification({Title = "Erro", Content = "Não foi possível encontrar seu time. Entre em uma equipe.", Time = 5})
  80. return nil
  81. end
  82.  
  83. local playerTeamColor = playerTeam.TeamColor
  84. local closestPile, minDistance = nil, math.huge
  85.  
  86. for _, part in ipairs(workspace:GetDescendants()) do
  87. if part:IsA("BasePart") and part.Parent and part.Parent:IsA("Model") then
  88. local nameLower = part.Parent.Name:lower()
  89. local containsKeyword = false
  90. for _, keyword in ipairs(CONFIG.PILE_KEYWORDS) do
  91. if nameLower:find(keyword) then
  92. containsKeyword = true
  93. break
  94. end
  95. end
  96.  
  97. -- Verifica se a parte tem a cor do time e se o nome do modelo contém uma palavra-chave
  98. if containsKeyword and part.BrickColor == playerTeamColor then
  99. local distance = (rootPart.Position - part.Position).Magnitude
  100. if distance < minDistance then
  101. minDistance = distance
  102. closestPile = part
  103. end
  104. end
  105. end
  106. end
  107.  
  108. if closestPile then
  109. OrionLib:MakeNotification({Title = "Sucesso!", Content = "Pilha de blocos do seu time encontrada!", Time = 3})
  110. return closestPile.Position
  111. else
  112. OrionLib:MakeNotification({Title = "Aviso!", Content = "Não foi possível encontrar a pilha de blocos automaticamente.", Time = 7})
  113. return nil
  114. end
  115. end
  116.  
  117. --=================================================================================================
  118. -- >> CRIAÇÃO DA INTERFACE (UI) COM ORION LIBRARY <<
  119. --=================================================================================================
  120.  
  121. -- Cria a janela principal, que já é arrastável e pode ser aberta/fechada.
  122. local Window = OrionLib:MakeWindow({
  123. Name = "Auto Block System by AI",
  124. HidePremium = true,
  125. SaveConfig = true,
  126. ConfigFolder = "Orion_Config_ABS",
  127. IntroEnabled = false -- Desativa a animação de introdução para um visual mais limpo
  128. })
  129.  
  130. -- Cria a aba principal dentro da janela
  131. local AutoFarmTab = Window:MakeTab({
  132. Name = "Coleta Automática",
  133. Icon = "rbxassetid://13724819434", -- Ícone de bloco
  134. PremiumOnly = false
  135. })
  136.  
  137. -- Adiciona uma seção para organizar os controles
  138. AutoFarmTab:AddSection({ Name = "Controle Principal" })
  139.  
  140. -- Cria o botão de Ligar/Desligar (Toggle)
  141. AutoFarmTab:AddToggle({
  142. Name = "Ativar Coleta Automática de Blocos",
  143. Default = false,
  144. Callback = function(Value)
  145. isSystemEnabled = Value
  146. if isSystemEnabled then
  147. -- Ao ligar, tenta encontrar a pilha de blocos
  148. blockPilePosition = findBlockPile()
  149. if not blockPilePosition then
  150. isSystemEnabled = false -- Desativa se não encontrar, para evitar erros
  151. OrionLib:MakeNotification({Title = "Falha!", Content = "Sistema desativado. Pilha de blocos não encontrada.", Time = 5})
  152. -- A UI do toggle pode precisar ser resetada manualmente aqui, mas geralmente o OrionLib cuida disso.
  153. else
  154. OrionLib:MakeNotification({Title = "Sistema Ativado!", Content = "Aguardando inventário ficar vazio...", Time = 3})
  155. end
  156. else
  157. OrionLib:MakeNotification({Title = "Sistema Desativado!", Content = "A coleta automática foi parada.", Time = 3})
  158. end
  159. end
  160. })
  161.  
  162. -- Adiciona uma seção para mostrar informações em tempo real
  163. AutoFarmTab:AddSection({ Name = "Status" })
  164.  
  165. -- Label para mostrar o status (Ativado/Desativado)
  166. local StatusLabel = AutoFarmTab:AddLabel("Status: Desativado")
  167.  
  168. -- Label para mostrar a contagem de blocos
  169. local BlockCountLabel = AutoFarmTab:AddLabel("Blocos no inventário: 0")
  170.  
  171. --=================================================================================================
  172. -- >> LOOP PRINCIPAL E LÓGICA DE TELEPORTE <<
  173. --=================================================================================================
  174.  
  175. RunService.Heartbeat:Connect(function()
  176. -- Atualiza as informações na UI a cada frame
  177. local blockCount = getInventoryBlockCount()
  178. BlockCountLabel:Set("Blocos no inventário: " .. blockCount)
  179. StatusLabel:Set(isSystemEnabled and "Status: ATIVADO" or "Status: Desativado")
  180.  
  181. -- Validações para executar a lógica principal
  182. if not isSystemEnabled or isTeleporting or blockCount > 0 then
  183. return
  184. end
  185.  
  186. local character = LocalPlayer.Character
  187. local rootPart = character and character:FindFirstChild("HumanoidRootPart")
  188. local humanoid = character and character:FindFirstChildOfClass("Humanoid")
  189.  
  190. if not rootPart or not humanoid or humanoid.Health <= 0 then
  191. return
  192. end
  193.  
  194. -- Confere se a posição da pilha é válida
  195. if not blockPilePosition then return end
  196.  
  197. -- 1. Inicia o processo e "trava" o script para evitar repetições
  198. isTeleporting = true
  199.  
  200. -- 2. Salva a posição e orientação EXATAS antes de teleportar
  201. previousCFrame = rootPart.CFrame
  202.  
  203. -- 3. Teleporta para o centro da pilha de blocos
  204. -- Adicionamos um pequeno offset no Y para não ficar preso dentro do chão
  205. rootPart.CFrame = CFrame.new(blockPilePosition + Vector3.new(0, 3.5, 0))
  206.  
  207. -- 4. Aguarda a coleta do bloco com um sistema de timeout para não ficar preso
  208. local blockCollected = false
  209. local connection
  210. local timeoutCoroutine = coroutine.create(function()
  211. task.wait(CONFIG.TELEPORT_TIMEOUT)
  212. if not blockCollected then
  213. if connection then connection:Disconnect() end
  214. OrionLib:MakeNotification({Title = "Timeout!", Content = "Retornando para a posição anterior.", Time = 3})
  215. if rootPart and previousCFrame then
  216. rootPart.CFrame = previousCFrame
  217. end
  218. isTeleporting = false
  219. end
  220. end)
  221. coroutine.resume(timeoutCoroutine)
  222.  
  223. -- Ouve o evento de um item ser adicionado ao inventário
  224. connection = LocalPlayer.Backpack.ChildAdded:Connect(function(child)
  225. if child:IsA("Tool") and table.find(CONFIG.BLOCK_TOOL_NAMES, child.Name) then
  226. blockCollected = true
  227. if connection then connection:Disconnect() end
  228.  
  229. -- 5. Retorna à posição anterior IMEDIATAMENTE
  230. if rootPart and previousCFrame then
  231. rootPart.CFrame = previousCFrame
  232. end
  233.  
  234. -- Pequena espera para o jogo processar tudo
  235. task.wait()
  236.  
  237. -- 6. Equipa o bloco recém-adquirido
  238. if humanoid and LocalPlayer.Backpack:FindFirstChild(child.Name) then
  239. humanoid:EquipTool(LocalPlayer.Backpack[child.Name])
  240. end
  241.  
  242. -- 7. Libera a "trava" para permitir um novo ciclo quando necessário
  243. isTeleporting = false
  244. end
  245. end)
  246. end)
  247.  
  248. -- Inicializa a biblioteca (necessário para que a janela apareça)
  249. OrionLib:Init()
Advertisement
Add Comment
Please, Sign In to add comment