Posted
Hi, I need help making a script for farming Pipe machines in Fantastic Frontier!
The script I made so far doesnt seem to work and I was wondering if someone could help.
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
-- == UI Creation ==
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "PipeMachineCollectorGui"
screenGui.Parent = playerGui
screenGui.ResetOnSpawn = false -- Keeps the GUI after you die
screenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
local frame = Instance.new("Frame")
frame.Name = "MainFrame"
frame.Parent = screenGui
frame.Size = UDim2.new(0, 150, 0, 50)
frame.Position = UDim2.new(0, 10, 0, 10)
frame.BackgroundColor3 = Color3.new(0.1, 0.1, 0.1)
frame.BorderSizePixel = 1
frame.BorderColor3 = Color3.new(0.5, 0.5, 0.5)
frame.Draggable = true -- Allow the user to move the frame
local toggleButton = Instance.new("TextButton")
toggleButton.Name = "ToggleButton"
toggleButton.Parent = frame
toggleButton.Size = UDim2.new(1, -10, 1, -10)
toggleButton.Position = UDim2.new(0, 5, 0, 5)
toggleButton.BackgroundColor3 = Color3.new(0.2, 0.6, 0.2) -- Green for OFF
toggleButton.BorderSizePixel = 0
toggleButton.Font = Enum.Font.SourceSansBold
toggleButton.Text = "START"
toggleButton.TextColor3 = Color3.new(1, 1, 1)
toggleButton.TextSize = 18
local statusLabel = Instance.new("TextLabel")
statusLabel.Name = "StatusLabel"
statusLabel.Parent = frame
statusLabel.Size = UDim2.new(1, 0, 0, 20)
statusLabel.Position = UDim2.new(0, 0, 1, 5) -- Position below the button
statusLabel.BackgroundColor3 = Color3.new(0, 0, 0)
statusLabel.BackgroundTransparency = 1
statusLabel.BorderSizePixel = 0
statusLabel.Font = Enum.Font.SourceSans
statusLabel.Text = "Status: Idle"
statusLabel.TextColor3 = Color3.new(1, 1, 1)
statusLabel.TextSize = 14
statusLabel.TextXAlignment = Enum.TextXAlignment.Center
-- Adjust frame size to fit the new label
frame.Size = UDim2.new(0, 150, 0, 75)
-- == Script Logic ==
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local isCollecting = false
local connection = nil
local pipeMachineModel = ReplicatedStorage:WaitForChild("Spawnables"):WaitForChild("Mushrooms"):WaitForChild("PipeMachine"):WaitForChild("Pipe Machine")
local function collectPipeMachine(machineInstance)
if not machineInstance or not machineInstance:IsDescendantOf(workspace) then
return
end
local targetCFrame = machineInstance.CFrame
local teleportInfo = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local teleportTween = TweenService:Create(humanoidRootPart, teleportInfo, {CFrame = targetCFrame})
statusLabel.Text = "Status: Teleporting..."
teleportTween:Play()
teleportTween.Completed:Wait()
local remoteEvent = machineInstance:FindFirstChildWhichIsA("RemoteEvent")
if remoteEvent then
statusLabel.Text = "Status: Collecting..."
pcall(function()
remoteEvent:FireServer()
end)
wait(0.2)
else
local prompt = machineInstance:FindFirstChildWhichIsA("ProximityPrompt")
if prompt then
statusLabel.Text = "Status: Interacting..."
wait(1) -- Simulate interaction time
end
end
end
local function collectLoop()
while isCollecting do
local foundMachines = 0
for _, machine in pairs(workspace:GetDescendants()) do
if not isCollecting then break end -- Stop loop if toggled off mid-cycle
if machine:IsA("Model") and machine.Name == pipeMachineModel.Name then
if machine:FindFirstChild("Mesh") then
collectPipeMachine(machine)
foundMachines = foundMachines + 1
wait(0.5)
end
end
end
if isCollecting then
if foundMachines > 0 then
statusLabel.Text = "Status: Cycle Complete"
else
statusLabel.Text = "Status: No Machines Found"
end
wait(10) -- Wait before starting the next cycle
end
end
statusLabel.Text = "Status: Idle"
end
-- == Toggle Functionality ==
toggleButton.MouseButton1Click:Connect(function()
isCollecting = not isCollecting
if isCollecting then
-- Start collecting
toggleButton.Text = "STOP"
toggleButton.BackgroundColor3 = Color3.new(0.8, 0.2, 0.2) -- Red for ON
statusLabel.Text = "Status: Starting..."
connection = task.spawn(collectLoop) -- Use task.spawn for better performance
else
-- Stop collecting
toggleButton.Text = "START"
toggleButton.BackgroundColor3 = Color3.new(0.2, 0.6, 0.2) -- Green for OFF
statusLabel.Text = "Status: Stopping..."
if connection then
task.cancel(connection)
connection = nil
end
end
end)
Users viewing this thread:
( Members: 0, Guests: 1, Total: 1 )
Cancel
Post