Idisjsusus

Generator Gui

Mar 4th, 2025
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.02 KB | None | 0 0
  1. local player = game.Players.LocalPlayer
  2. local playerName = player.Name
  3. local survivorsFolder = workspace:WaitForChild("Players"):WaitForChild("Survivors")
  4.  
  5. local screenGui = Instance.new("ScreenGui")
  6. screenGui.Parent = cloneref(game:GetService("CoreGui"))
  7.  
  8. -- Variáveis para controlar o modo automático e o tempo
  9. local autoModeEnabled = true
  10. local autoModeTime = 2 -- Tempo padrão de 2 segundos
  11.  
  12. -- Função para criar um frame com bordas arredondadas
  13. local function createRoundedFrame(parent, size, position, color)
  14. local frame = Instance.new("Frame")
  15. frame.Parent = parent
  16. frame.Size = size
  17. frame.Position = position
  18. frame.BackgroundColor3 = color
  19. frame.BackgroundTransparency = 0.2
  20. frame.BorderSizePixel = 0
  21.  
  22. local corner = Instance.new("UICorner")
  23. corner.Parent = frame
  24. corner.CornerRadius = UDim.new(0, 8)
  25.  
  26. return frame
  27. end
  28.  
  29. -- Função para criar um botão estilizado
  30. local function createStyledButton(parent, size, position, text, color)
  31. local button = Instance.new("TextButton")
  32. button.Parent = parent
  33. button.Size = size
  34. button.Position = position
  35. button.Text = text
  36. button.BackgroundColor3 = color
  37. button.TextColor3 = Color3.new(1, 1, 1) -- Texto branco
  38. button.Font = Enum.Font.SourceSansBold -- Fonte moderna
  39. button.TextSize = 14
  40. button.AutoButtonColor = false -- Desativa a cor automática do botão
  41. button.Draggable = false -- Botão não pode ser arrastado
  42. button.Active = true
  43.  
  44. local corner = Instance.new("UICorner")
  45. corner.Parent = button
  46. corner.CornerRadius = UDim.new(0, 8)
  47.  
  48. return button
  49. end
  50.  
  51. -- Função para criar o botão principal "Do Generator"
  52. local function createMainButton()
  53. local mainFrame = createRoundedFrame(screenGui, UDim2.new(0, 150, 0, 50), UDim2.new(0.5, -75, 0.9, -25), Color3.fromRGB(40, 40, 40))
  54. local button = createStyledButton(mainFrame, UDim2.new(1, 0, 1, 0), UDim2.new(0, 0, 0, 0), "Do Generator", Color3.fromRGB(40, 40, 40))
  55.  
  56. -- Efeitos visuais do botão principal
  57. button.MouseEnter:Connect(function()
  58. button.BackgroundColor3 = Color3.fromRGB(60, 60, 60) -- Cor mais clara ao passar o mouse
  59. end)
  60.  
  61. button.MouseLeave:Connect(function()
  62. button.BackgroundColor3 = Color3.fromRGB(40, 40, 40) -- Volta à cor original
  63. end)
  64.  
  65. button.MouseButton1Down:Connect(function()
  66. button.BackgroundColor3 = Color3.fromRGB(80, 80, 80) -- Cor mais clara ao clicar
  67. end)
  68.  
  69. button.MouseButton1Up:Connect(function()
  70. button.BackgroundColor3 = Color3.fromRGB(60, 60, 60) -- Volta à cor do hover
  71. end)
  72.  
  73. return button, mainFrame
  74. end
  75.  
  76. -- Função para criar o botão de automação "🤖" e a TextBox
  77. local function createAutoButtonAndTextBox(mainFrame)
  78. local container = createRoundedFrame(mainFrame, UDim2.new(0, 100, 0, 30), UDim2.new(0, 0, 0, -40), Color3.fromRGB(40, 40, 40))
  79. container.BackgroundTransparency = 1 -- Fundo transparente
  80.  
  81. -- Botão de automação "🤖"
  82. local autoButton = createStyledButton(container, UDim2.new(0, 30, 0, 30), UDim2.new(0, 0, 0, 0), "🤖", Color3.fromRGB(50, 200, 50))
  83.  
  84. -- Efeitos visuais do botão de automação
  85. autoButton.MouseEnter:Connect(function()
  86. autoButton.BackgroundColor3 = autoModeEnabled and Color3.fromRGB(70, 220, 70) or Color3.fromRGB(220, 70, 70)
  87. end)
  88.  
  89. autoButton.MouseLeave:Connect(function()
  90. autoButton.BackgroundColor3 = autoModeEnabled and Color3.fromRGB(50, 200, 50) or Color3.fromRGB(200, 50, 50)
  91. end)
  92.  
  93. autoButton.MouseButton1Down:Connect(function()
  94. autoButton.BackgroundColor3 = autoModeEnabled and Color3.fromRGB(90, 240, 90) or Color3.fromRGB(240, 90, 90)
  95. end)
  96.  
  97. autoButton.MouseButton1Up:Connect(function()
  98. autoButton.BackgroundColor3 = autoModeEnabled and Color3.fromRGB(70, 220, 70) or Color3.fromRGB(220, 70, 70)
  99. end)
  100.  
  101. -- Função para alternar o modo automático
  102. autoButton.MouseButton1Click:Connect(function()
  103. autoModeEnabled = not autoModeEnabled -- Alterna entre ativado e desativado
  104. autoButton.BackgroundColor3 = autoModeEnabled and Color3.fromRGB(50, 200, 50) or Color3.fromRGB(200, 50, 50)
  105. print("Modo automático:", autoModeEnabled and "Ativado" or "Desativado")
  106. end)
  107.  
  108. -- TextBox para ajustar o tempo do modo automático
  109. local timeTextBox = Instance.new("TextBox")
  110. timeTextBox.Parent = container
  111. timeTextBox.Size = UDim2.new(0, 60, 0, 30)
  112. timeTextBox.Position = UDim2.new(0, 35, 0, 0)
  113. timeTextBox.Text = tostring(autoModeTime) -- Tempo padrão
  114. timeTextBox.BackgroundColor3 = Color3.fromRGB(255, 255, 255) -- Fundo branco
  115. timeTextBox.TextColor3 = Color3.new(0, 0, 0) -- Texto preto
  116. timeTextBox.Font = Enum.Font.SourceSansBold -- Fonte moderna
  117. timeTextBox.TextSize = 14
  118. timeTextBox.PlaceholderText = "Tempo (s)"
  119. timeTextBox.ClearTextOnFocus = false
  120.  
  121. local corner = Instance.new("UICorner")
  122. corner.Parent = timeTextBox
  123. corner.CornerRadius = UDim.new(0, 8)
  124.  
  125. -- Função para validar o tempo inserido
  126. timeTextBox.FocusLost:Connect(function()
  127. local newTime = tonumber(timeTextBox.Text)
  128. if newTime and newTime >= 2 then
  129. autoModeTime = newTime
  130. print("Tempo do modo automático ajustado para:", autoModeTime, "segundos")
  131. else
  132. timeTextBox.Text = tostring(autoModeTime) -- Restaura o valor anterior
  133. warn("O tempo deve ser 2 ou maior!")
  134. end
  135. end)
  136.  
  137. return autoButton, timeTextBox, container
  138. end
  139.  
  140. -- Função para criar o botão de ocultar/reativar a GUI
  141. local function createToggleGUIButton()
  142. local toggleButton = createStyledButton(screenGui, UDim2.new(0, 40, 0, 40), UDim2.new(0, 10, 0, 10), "👁️", Color3.fromRGB(40, 40, 40))
  143. toggleButton.Draggable = false -- Não pode ser arrastado
  144.  
  145. return toggleButton
  146. end
  147.  
  148. -- Função para encontrar o gerador mais próximo
  149. local function getNearestGenerator()
  150. local playerModel = nil
  151. for _, model in pairs(survivorsFolder:GetChildren()) do
  152. if model:IsA("Model") and model:GetAttribute("Username") == playerName then
  153. playerModel = model
  154. break
  155. end
  156. end
  157.  
  158. if not playerModel then
  159. warn("Player model not found in Survivors folder!")
  160. return
  161. end
  162.  
  163. local rootPart = playerModel:WaitForChild("HumanoidRootPart")
  164. local closestGen = nil
  165. local shortestDist = math.huge
  166.  
  167. local map = workspace:WaitForChild("Map"):WaitForChild("Ingame"):WaitForChild("Map")
  168.  
  169. for _, obj in pairs(map:GetChildren()) do
  170. if obj:IsA("Model") and obj.Name == "Generator" then
  171. local primaryPart = obj.PrimaryPart or obj:FindFirstChild("PrimaryPart")
  172. if primaryPart then
  173. local dist = (primaryPart.Position - rootPart.Position).Magnitude
  174. if dist < shortestDist then
  175. shortestDist = dist
  176. closestGen = obj
  177. end
  178. end
  179. end
  180. end
  181.  
  182. return closestGen
  183. end
  184.  
  185. -- Função para interagir manualmente com o gerador
  186. local function doGeneratorManually()
  187. local nearestGen = getNearestGenerator()
  188. if nearestGen then
  189. local remotes = nearestGen:WaitForChild("Remotes")
  190. remotes:WaitForChild("RE"):FireServer() -- Interage com o gerador
  191. print("Gerador feito manualmente!")
  192. else
  193. warn("No nearby generator found!")
  194. end
  195. end
  196.  
  197. -- Função para automatizar a interação com o gerador
  198. local function automateGenerator()
  199. while true do
  200. if autoModeEnabled then
  201. local nearestGen = getNearestGenerator()
  202. if nearestGen then
  203. local remotes = nearestGen:WaitForChild("Remotes")
  204. remotes:WaitForChild("RE"):FireServer() -- Interage com o gerador
  205. task.wait(autoModeTime) -- Espera o tempo ajustado pelo jogador
  206. else
  207. warn("No nearby generator found!")
  208. task.wait(autoModeTime) -- Espera o tempo ajustado pelo jogador
  209. end
  210. else
  211. task.wait(1) -- Espera 1 segundo se o modo automático estiver desativado
  212. end
  213. end
  214. end
  215.  
  216. -- Cria os botões
  217. local mainButton, mainFrame = createMainButton()
  218. local autoButton, timeTextBox, autoContainer = createAutoButtonAndTextBox(mainFrame)
  219. local toggleButton = createToggleGUIButton()
  220.  
  221. -- Variável para controlar a visibilidade da GUI
  222. local guiVisible = true
  223.  
  224. -- Função para alternar a visibilidade da GUI
  225. toggleButton.MouseButton1Click:Connect(function()
  226. guiVisible = not guiVisible
  227. mainFrame.Visible = guiVisible
  228. autoContainer.Visible = guiVisible
  229. toggleButton.Text = guiVisible and "👁️" or "👁️‍🗨️"
  230. print("GUI visível:", guiVisible)
  231. end)
  232.  
  233. -- Adiciona a funcionalidade manual ao botão principal
  234. mainButton.MouseButton1Click:Connect(function()
  235. doGeneratorManually()
  236. end)
  237.  
  238. -- Inicia a automação em uma nova thread
  239. coroutine.wrap(automateGenerator)()
Advertisement
Add Comment
Please, Sign In to add comment