Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game.Players.LocalPlayer
- local playerName = player.Name
- local survivorsFolder = workspace:WaitForChild("Players"):WaitForChild("Survivors")
- local screenGui = Instance.new("ScreenGui")
- screenGui.Parent = cloneref(game:GetService("CoreGui"))
- -- Variáveis para controlar o modo automático e o tempo
- local autoModeEnabled = true
- local autoModeTime = 2 -- Tempo padrão de 2 segundos
- -- Função para criar um frame com bordas arredondadas
- local function createRoundedFrame(parent, size, position, color)
- local frame = Instance.new("Frame")
- frame.Parent = parent
- frame.Size = size
- frame.Position = position
- frame.BackgroundColor3 = color
- frame.BackgroundTransparency = 0.2
- frame.BorderSizePixel = 0
- local corner = Instance.new("UICorner")
- corner.Parent = frame
- corner.CornerRadius = UDim.new(0, 8)
- return frame
- end
- -- Função para criar um botão estilizado
- local function createStyledButton(parent, size, position, text, color)
- local button = Instance.new("TextButton")
- button.Parent = parent
- button.Size = size
- button.Position = position
- button.Text = text
- button.BackgroundColor3 = color
- button.TextColor3 = Color3.new(1, 1, 1) -- Texto branco
- button.Font = Enum.Font.SourceSansBold -- Fonte moderna
- button.TextSize = 14
- button.AutoButtonColor = false -- Desativa a cor automática do botão
- button.Draggable = false -- Botão não pode ser arrastado
- button.Active = true
- local corner = Instance.new("UICorner")
- corner.Parent = button
- corner.CornerRadius = UDim.new(0, 8)
- return button
- end
- -- Função para criar o botão principal "Do Generator"
- local function createMainButton()
- local mainFrame = createRoundedFrame(screenGui, UDim2.new(0, 150, 0, 50), UDim2.new(0.5, -75, 0.9, -25), Color3.fromRGB(40, 40, 40))
- local button = createStyledButton(mainFrame, UDim2.new(1, 0, 1, 0), UDim2.new(0, 0, 0, 0), "Do Generator", Color3.fromRGB(40, 40, 40))
- -- Efeitos visuais do botão principal
- button.MouseEnter:Connect(function()
- button.BackgroundColor3 = Color3.fromRGB(60, 60, 60) -- Cor mais clara ao passar o mouse
- end)
- button.MouseLeave:Connect(function()
- button.BackgroundColor3 = Color3.fromRGB(40, 40, 40) -- Volta à cor original
- end)
- button.MouseButton1Down:Connect(function()
- button.BackgroundColor3 = Color3.fromRGB(80, 80, 80) -- Cor mais clara ao clicar
- end)
- button.MouseButton1Up:Connect(function()
- button.BackgroundColor3 = Color3.fromRGB(60, 60, 60) -- Volta à cor do hover
- end)
- return button, mainFrame
- end
- -- Função para criar o botão de automação "🤖" e a TextBox
- local function createAutoButtonAndTextBox(mainFrame)
- local container = createRoundedFrame(mainFrame, UDim2.new(0, 100, 0, 30), UDim2.new(0, 0, 0, -40), Color3.fromRGB(40, 40, 40))
- container.BackgroundTransparency = 1 -- Fundo transparente
- -- Botão de automação "🤖"
- local autoButton = createStyledButton(container, UDim2.new(0, 30, 0, 30), UDim2.new(0, 0, 0, 0), "🤖", Color3.fromRGB(50, 200, 50))
- -- Efeitos visuais do botão de automação
- autoButton.MouseEnter:Connect(function()
- autoButton.BackgroundColor3 = autoModeEnabled and Color3.fromRGB(70, 220, 70) or Color3.fromRGB(220, 70, 70)
- end)
- autoButton.MouseLeave:Connect(function()
- autoButton.BackgroundColor3 = autoModeEnabled and Color3.fromRGB(50, 200, 50) or Color3.fromRGB(200, 50, 50)
- end)
- autoButton.MouseButton1Down:Connect(function()
- autoButton.BackgroundColor3 = autoModeEnabled and Color3.fromRGB(90, 240, 90) or Color3.fromRGB(240, 90, 90)
- end)
- autoButton.MouseButton1Up:Connect(function()
- autoButton.BackgroundColor3 = autoModeEnabled and Color3.fromRGB(70, 220, 70) or Color3.fromRGB(220, 70, 70)
- end)
- -- Função para alternar o modo automático
- autoButton.MouseButton1Click:Connect(function()
- autoModeEnabled = not autoModeEnabled -- Alterna entre ativado e desativado
- autoButton.BackgroundColor3 = autoModeEnabled and Color3.fromRGB(50, 200, 50) or Color3.fromRGB(200, 50, 50)
- print("Modo automático:", autoModeEnabled and "Ativado" or "Desativado")
- end)
- -- TextBox para ajustar o tempo do modo automático
- local timeTextBox = Instance.new("TextBox")
- timeTextBox.Parent = container
- timeTextBox.Size = UDim2.new(0, 60, 0, 30)
- timeTextBox.Position = UDim2.new(0, 35, 0, 0)
- timeTextBox.Text = tostring(autoModeTime) -- Tempo padrão
- timeTextBox.BackgroundColor3 = Color3.fromRGB(255, 255, 255) -- Fundo branco
- timeTextBox.TextColor3 = Color3.new(0, 0, 0) -- Texto preto
- timeTextBox.Font = Enum.Font.SourceSansBold -- Fonte moderna
- timeTextBox.TextSize = 14
- timeTextBox.PlaceholderText = "Tempo (s)"
- timeTextBox.ClearTextOnFocus = false
- local corner = Instance.new("UICorner")
- corner.Parent = timeTextBox
- corner.CornerRadius = UDim.new(0, 8)
- -- Função para validar o tempo inserido
- timeTextBox.FocusLost:Connect(function()
- local newTime = tonumber(timeTextBox.Text)
- if newTime and newTime >= 2 then
- autoModeTime = newTime
- print("Tempo do modo automático ajustado para:", autoModeTime, "segundos")
- else
- timeTextBox.Text = tostring(autoModeTime) -- Restaura o valor anterior
- warn("O tempo deve ser 2 ou maior!")
- end
- end)
- return autoButton, timeTextBox, container
- end
- -- Função para criar o botão de ocultar/reativar a GUI
- local function createToggleGUIButton()
- local toggleButton = createStyledButton(screenGui, UDim2.new(0, 40, 0, 40), UDim2.new(0, 10, 0, 10), "👁️", Color3.fromRGB(40, 40, 40))
- toggleButton.Draggable = false -- Não pode ser arrastado
- return toggleButton
- end
- -- Função para encontrar o gerador mais próximo
- local function getNearestGenerator()
- local playerModel = nil
- for _, model in pairs(survivorsFolder:GetChildren()) do
- if model:IsA("Model") and model:GetAttribute("Username") == playerName then
- playerModel = model
- break
- end
- end
- if not playerModel then
- warn("Player model not found in Survivors folder!")
- return
- end
- local rootPart = playerModel:WaitForChild("HumanoidRootPart")
- local closestGen = nil
- local shortestDist = math.huge
- local map = workspace:WaitForChild("Map"):WaitForChild("Ingame"):WaitForChild("Map")
- for _, obj in pairs(map:GetChildren()) do
- if obj:IsA("Model") and obj.Name == "Generator" then
- local primaryPart = obj.PrimaryPart or obj:FindFirstChild("PrimaryPart")
- if primaryPart then
- local dist = (primaryPart.Position - rootPart.Position).Magnitude
- if dist < shortestDist then
- shortestDist = dist
- closestGen = obj
- end
- end
- end
- end
- return closestGen
- end
- -- Função para interagir manualmente com o gerador
- local function doGeneratorManually()
- local nearestGen = getNearestGenerator()
- if nearestGen then
- local remotes = nearestGen:WaitForChild("Remotes")
- remotes:WaitForChild("RE"):FireServer() -- Interage com o gerador
- print("Gerador feito manualmente!")
- else
- warn("No nearby generator found!")
- end
- end
- -- Função para automatizar a interação com o gerador
- local function automateGenerator()
- while true do
- if autoModeEnabled then
- local nearestGen = getNearestGenerator()
- if nearestGen then
- local remotes = nearestGen:WaitForChild("Remotes")
- remotes:WaitForChild("RE"):FireServer() -- Interage com o gerador
- task.wait(autoModeTime) -- Espera o tempo ajustado pelo jogador
- else
- warn("No nearby generator found!")
- task.wait(autoModeTime) -- Espera o tempo ajustado pelo jogador
- end
- else
- task.wait(1) -- Espera 1 segundo se o modo automático estiver desativado
- end
- end
- end
- -- Cria os botões
- local mainButton, mainFrame = createMainButton()
- local autoButton, timeTextBox, autoContainer = createAutoButtonAndTextBox(mainFrame)
- local toggleButton = createToggleGUIButton()
- -- Variável para controlar a visibilidade da GUI
- local guiVisible = true
- -- Função para alternar a visibilidade da GUI
- toggleButton.MouseButton1Click:Connect(function()
- guiVisible = not guiVisible
- mainFrame.Visible = guiVisible
- autoContainer.Visible = guiVisible
- toggleButton.Text = guiVisible and "👁️" or "👁️🗨️"
- print("GUI visível:", guiVisible)
- end)
- -- Adiciona a funcionalidade manual ao botão principal
- mainButton.MouseButton1Click:Connect(function()
- doGeneratorManually()
- end)
- -- Inicia a automação em uma nova thread
- coroutine.wrap(automateGenerator)()
Advertisement
Add Comment
Please, Sign In to add comment