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"))
- local button = Instance.new("TextButton")
- button.Parent = screenGui
- button.Size = UDim2.new(0, 120, 0, 50)
- button.Position = UDim2.new(0.5, -60, 0.5, -25)
- button.Text = "Do Generator"
- button.BackgroundColor3 = Color3.fromRGB(50, 200, 50)
- button.TextColor3 = Color3.new(1, 1, 1)
- button.Font = Enum.Font.SourceSansBold
- button.TextSize = 14
- button.AutoButtonColor = false
- button.Draggable = true
- button.Active = true
- -- Adicionando bordas arredondadas
- local corner = Instance.new("UICorner")
- corner.CornerRadius = UDim.new(0, 8)
- corner.Parent = button
- -- Adicionando sombra
- local shadow = Instance.new("UIStroke")
- shadow.Color = Color3.fromRGB(0, 0, 0)
- shadow.Thickness = 2
- shadow.Transparency = 0.5
- shadow.Parent = button
- -- Adicionando efeito de hover
- button.MouseEnter:Connect(function()
- game:GetService("TweenService"):Create(button, TweenInfo.new(0.2), {BackgroundColor3 = Color3.fromRGB(70, 220, 70)}):Play()
- end)
- button.MouseLeave:Connect(function()
- game:GetService("TweenService"):Create(button, TweenInfo.new(0.2), {BackgroundColor3 = Color3.fromRGB(50, 200, 50)}):Play()
- end)
- local cooldown = false
- 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
- button.MouseButton1Click:Connect(function()
- if cooldown then return end
- cooldown = true
- button.Text = "Cooldown"
- button.BackgroundColor3 = Color3.fromRGB(200, 50, 50)
- local nearestGen = getNearestGenerator()
- if nearestGen then
- local remotes = nearestGen:WaitForChild("Remotes")
- -- Executa todas as partes do gerador
- for _, remote in pairs(remotes:GetChildren()) do
- if remote.Name == "RE" then
- remote:FireServer() -- Executa a ação do gerador
- elseif remote.Name == "RF" then
- remote:InvokeServer("complete") -- Completa o gerador (se necessário)
- end
- end
- else
- warn("No nearby generator found!")
- end
- task.wait(1)
- button.Text = "Do Generator"
- button.BackgroundColor3 = Color3.fromRGB(50, 200, 50)
- cooldown = false
- end)
Advertisement
Add Comment
Please, Sign In to add comment