You are on page 1of 9

--Another LuaPhysics GUI

local FarmTownAutoFarm = Instance.new("ScreenGui")


local OpenFrame = Instance.new("Frame")
local Open = Instance.new("TextButton")
local Main = Instance.new("Frame")
local UI_Design = Instance.new("Frame")
local FarmGround = Instance.new("ImageLabel")
local LuaPhysicsWasHere = Instance.new("ImageLabel")
local TopBar = Instance.new("TextLabel")
local BottomBar = Instance.new("TextLabel")
local Help = Instance.new("Frame")
local Instructions = Instance.new("TextLabel")
local ChooseSeed = Instance.new("Frame")
local Seed = Instance.new("TextButton")
local Values = Instance.new("TextBox")
local AutoFarming = Instance.new("Frame")
local OFF = Instance.new("TextButton")
local ON = Instance.new("TextButton")
local Label1 = Instance.new("TextLabel")
local OutBox = Instance.new("Frame")
local Label2 = Instance.new("TextLabel")
local NO = Instance.new("TextButton")
local YES = Instance.new("TextButton")
local Close = Instance.new("TextButton")
--Properties:
FarmTownAutoFarm.Name = "Farm Town Auto-Farm"
FarmTownAutoFarm.Parent = game.CoreGui

OpenFrame.Name = "OpenFrame"
OpenFrame.Parent = FarmTownAutoFarm
OpenFrame.BackgroundColor3 = Color3.new(1, 1, 1)
OpenFrame.BorderColor3 = Color3.new(0, 0, 0)
OpenFrame.BorderSizePixel = 4
OpenFrame.Position = UDim2.new(0, 0, 0.646302283, 0)
OpenFrame.Size = UDim2.new(0, 109, 0, 39)

Open.Name = "Open"
Open.Parent = OpenFrame
Open.BackgroundColor3 = Color3.new(0.0784314, 0.0784314, 0.0784314)
Open.BorderColor3 = Color3.new(0, 0, 0)
Open.BorderSizePixel = 0
Open.Size = UDim2.new(0, 109, 0, 39)
Open.Font = Enum.Font.SciFi
Open.Text = "OPEN"
Open.TextColor3 = Color3.new(1, 1, 1)
Open.TextScaled = true
Open.TextSize = 14
Open.TextStrokeTransparency = 0
Open.TextWrapped = true
Open.MouseButton1Down:connect(function()
Main.Visible = true
OpenFrame.Visible = false
end)

Main.Name = "Main"
Main.Parent = FarmTownAutoFarm
Main.Active = true
Main.BackgroundColor3 = Color3.new(0.0784314, 0.0784314, 0.0784314)
Main.BorderColor3 = Color3.new(0, 0, 0)
Main.BorderSizePixel = 0
Main.Position = UDim2.new(0.386861324, 0, 0.485530555, 0)
Main.Size = UDim2.new(0, 280, 0, 214)
Main.Visible = false
Main.Draggable = true

UI_Design.Name = "UI_Design"
UI_Design.Parent = Main
UI_Design.BackgroundColor3 = Color3.new(1, 1, 1)
UI_Design.BackgroundTransparency = 1
UI_Design.Size = UDim2.new(0, 280, 0, 214)

FarmGround.Name = "FarmGround"
FarmGround.Parent = UI_Design
FarmGround.BackgroundColor3 = Color3.new(1, 1, 1)
FarmGround.BackgroundTransparency = 1
FarmGround.BorderSizePixel = 0
FarmGround.Position = UDim2.new(0, 0, 0.0607476644, 0)
FarmGround.Size = UDim2.new(0, 280, 0, 194)
FarmGround.Image = "rbxassetid://570297288"

LuaPhysicsWasHere.Name = "LuaPhysicsWasHere"
LuaPhysicsWasHere.Parent = UI_Design
LuaPhysicsWasHere.BackgroundColor3 = Color3.new(1, 1, 1)
LuaPhysicsWasHere.BackgroundTransparency = 1
LuaPhysicsWasHere.Position = UDim2.new(0.153571427, 0, 0.0594705343, 0)
LuaPhysicsWasHere.Size = UDim2.new(0, 194, 0, 194)
LuaPhysicsWasHere.Image = "rbxassetid://3095216806"
LuaPhysicsWasHere.ImageTransparency = 0.60000002384186

TopBar.Name = "TopBar"
TopBar.Parent = UI_Design
TopBar.BackgroundColor3 = Color3.new(0, 0, 0)
TopBar.BorderColor3 = Color3.new(0, 0, 0)
TopBar.BorderSizePixel = 0
TopBar.Size = UDim2.new(0, 280, 0, 13)
TopBar.Font = Enum.Font.Code
TopBar.Text = "FarmTown Auto-Farm"
TopBar.TextColor3 = Color3.new(1, 1, 1)
TopBar.TextSize = 14

BottomBar.Name = "BottomBar"
BottomBar.Parent = UI_Design
BottomBar.BackgroundColor3 = Color3.new(0, 0, 0)
BottomBar.BorderColor3 = Color3.new(0, 0, 0)
BottomBar.BorderSizePixel = 0
BottomBar.Position = UDim2.new(0, 0, 0.967289746, 0)
BottomBar.Size = UDim2.new(0, 280, 0, 7)
BottomBar.Font = Enum.Font.Code
BottomBar.Text = ""
BottomBar.TextColor3 = Color3.new(1, 1, 1)
BottomBar.TextSize = 14

Help.Name = "Help"
Help.Parent = Main
Help.BackgroundColor3 = Color3.new(0.0980392, 0.0980392, 0.0980392)
Help.BackgroundTransparency = 0.090000003576279
Help.BorderColor3 = Color3.new(0, 0, 0)
Help.BorderSizePixel = 2
Help.Position = UDim2.new(0.160714284, 0, 0.0934579447, 0)
Help.Size = UDim2.new(0, 190, 0, 64)

Instructions.Name = "Instructions"
Instructions.Parent = Help
Instructions.BackgroundColor3 = Color3.new(1, 1, 1)
Instructions.BackgroundTransparency = 1
Instructions.Size = UDim2.new(0, 190, 0, 64)
Instructions.Font = Enum.Font.SciFi
Instructions.Text = "Before Enabling Auto-Farm, Enter The Seed You Want To Farm and
Press \"Choose\"."
Instructions.TextColor3 = Color3.new(0, 1, 0.14902)
Instructions.TextScaled = true
Instructions.TextSize = 14
Instructions.TextStrokeTransparency = 0
Instructions.TextWrapped = true

ChooseSeed.Name = "ChooseSeed"
ChooseSeed.Parent = Main
ChooseSeed.BackgroundColor3 = Color3.new(1, 1, 1)
ChooseSeed.BackgroundTransparency = 1
ChooseSeed.Size = UDim2.new(0, 279, 0, 214)

Seed.Name = "Seed"
Seed.Parent = ChooseSeed
Seed.BackgroundColor3 = Color3.new(0.0784314, 0.0784314, 0.0784314)
Seed.BorderColor3 = Color3.new(0, 0, 0)
Seed.Position = UDim2.new(0.714285731, 0, 0.864485979, 0)
Seed.Size = UDim2.new(0, 51, 0, 15)
Seed.Font = Enum.Font.Code
Seed.Text = "Choose"
Seed.TextColor3 = Color3.new(1, 1, 1)
Seed.TextScaled = true
Seed.TextSize = 14
Seed.TextStrokeTransparency = 0
Seed.TextWrapped = true
Seed.MouseButton1Down:connect(function()
_G.seed = Values.Text --Which seed you want to plant
end)

Values.Name = "Values"
Values.Parent = ChooseSeed
Values.BackgroundColor3 = Color3.new(0.0784314, 0.0784314, 0.0784314)
Values.BackgroundTransparency = 0.20000000298023
Values.BorderColor3 = Color3.new(0, 0, 0)
Values.Position = UDim2.new(0.10357143, 0, 0.864485979, 0)
Values.Size = UDim2.new(0, 171, 0, 15)
Values.Font = Enum.Font.SciFi
Values.PlaceholderColor3 = Color3.new(1, 1, 1)
Values.PlaceholderText = "Seed Name Here"
Values.Text = ""
Values.TextColor3 = Color3.new(1, 1, 1)
Values.TextScaled = true
Values.TextSize = 14
Values.TextStrokeTransparency = 0
Values.TextWrapped = true

AutoFarming.Name = "AutoFarming"
AutoFarming.Parent = Main
AutoFarming.BackgroundColor3 = Color3.new(1, 1, 1)
AutoFarming.BackgroundTransparency = 1
AutoFarming.Size = UDim2.new(0, 280, 0, 214)

OFF.Name = "OFF"
OFF.Parent = AutoFarming
OFF.BackgroundColor3 = Color3.new(0.0784314, 0.0784314, 0.0784314)
OFF.BackgroundTransparency = 0.10000000149012
OFF.BorderColor3 = Color3.new(0, 0, 0)
OFF.BorderSizePixel = 2
OFF.Position = UDim2.new(0.678571463, 0, 0.461243004, 0)
OFF.Size = UDim2.new(0, 47, 0, 25)
OFF.Font = Enum.Font.SciFi
OFF.Text = "OFF"
OFF.TextColor3 = Color3.new(1, 0, 0)
OFF.TextScaled = true
OFF.TextSize = 14
OFF.TextStrokeTransparency = 0
OFF.TextWrapped = true
OFF.MouseButton1Down:connect(function()
_G.farming = true --Set this to false if you wanna buy seed or do other stuff
ON.Visible = true
OFF.Visible = false
end)

ON.Name = "ON"
ON.Parent = AutoFarming
ON.BackgroundColor3 = Color3.new(0.0784314, 0.0784314, 0.0784314)
ON.BackgroundTransparency = 0.10000000149012
ON.BorderColor3 = Color3.new(0, 0, 0)
ON.BorderSizePixel = 2
ON.Position = UDim2.new(0.67900002, 0, 0.460999995, 0)
ON.Size = UDim2.new(0, 48, 0, 25)
ON.Visible = false
ON.Font = Enum.Font.SciFi
ON.Text = "ON"
ON.TextColor3 = Color3.new(0, 1, 0)
ON.TextScaled = true
ON.TextSize = 14
ON.TextStrokeTransparency = 0
ON.TextWrapped = true
ON.MouseButton1Down:connect(function()
_G.farming = false --Set this to false if you wanna buy seed or do other
stuff
ON.Visible = false
OFF.Visible = true
end)

Label1.Name = "Label1"
Label1.Parent = AutoFarming
Label1.BackgroundColor3 = Color3.new(0.0784314, 0.0784314, 0.0784314)
Label1.BackgroundTransparency = 0.20000000298023
Label1.BorderColor3 = Color3.new(0, 0, 0)
Label1.BorderSizePixel = 2
Label1.Position = UDim2.new(0.153571427, 0, 0.461339653, 0)
Label1.Size = UDim2.new(0, 144, 0, 25)
Label1.Font = Enum.Font.Code
Label1.Text = "Auto-Farming"
Label1.TextColor3 = Color3.new(1, 1, 1)
Label1.TextScaled = true
Label1.TextSize = 14
Label1.TextStrokeTransparency = 0
Label1.TextWrapped = true

OutBox.Name = "OutBox"
OutBox.Parent = Main
OutBox.BackgroundColor3 = Color3.new(1, 1, 1)
OutBox.BackgroundTransparency = 1
OutBox.Size = UDim2.new(0, 279, 0, 214)

Label2.Name = "Label2"
Label2.Parent = OutBox
Label2.BackgroundColor3 = Color3.new(0.0784314, 0.0784314, 0.0784314)
Label2.BackgroundTransparency = 0.20000000298023
Label2.BorderColor3 = Color3.new(0, 0, 0)
Label2.BorderSizePixel = 2
Label2.Position = UDim2.new(0.153571427, 0, 0.643582642, 0)
Label2.Size = UDim2.new(0, 144, 0, 25)
Label2.Font = Enum.Font.Code
Label2.Text = "Out-Box"
Label2.TextColor3 = Color3.new(1, 1, 1)
Label2.TextScaled = true
Label2.TextSize = 14
Label2.TextStrokeTransparency = 0
Label2.TextWrapped = true

NO.Name = "NO"
NO.Parent = OutBox
NO.BackgroundColor3 = Color3.new(0.0784314, 0.0784314, 0.0784314)
NO.BackgroundTransparency = 0.10000000149012
NO.BorderColor3 = Color3.new(0, 0, 0)
NO.BorderSizePixel = 2
NO.Position = UDim2.new(0.678571463, 0, 0.643486023, 0)
NO.Size = UDim2.new(0, 47, 0, 25)
NO.Font = Enum.Font.SciFi
NO.Text = "NO"
NO.TextColor3 = Color3.new(1, 0, 0)
NO.TextScaled = true
NO.TextSize = 14
NO.TextStrokeTransparency = 0
NO.TextWrapped = true
NO.MouseButton1Down:connect(function()
_G.OutBox = true --Set this to true if you have an outbox
NO.Visible = false
YES.Visible = true

end)

YES.Name = "YES"
YES.Parent = OutBox
YES.BackgroundColor3 = Color3.new(0.0784314, 0.0784314, 0.0784314)
YES.BackgroundTransparency = 0.10000000149012
YES.BorderColor3 = Color3.new(0, 0, 0)
YES.BorderSizePixel = 2
YES.Position = UDim2.new(0.67900002, 0, 0.643242955, 0)
YES.Size = UDim2.new(0, 48, 0, 25)
YES.Visible = false
YES.Font = Enum.Font.SciFi
YES.Text = "YES"
YES.TextColor3 = Color3.new(0, 1, 0)
YES.TextScaled = true
YES.TextSize = 14
YES.TextStrokeTransparency = 0
YES.TextWrapped = true
YES.MouseButton1Down:connect(function()
_G.OutBox = false --Set this to true if you have an outbox
NO.Visible = true
YES.Visible = false

end)

Close.Name = "Close"
Close.Parent = Main
Close.BackgroundColor3 = Color3.new(1, 1, 1)
Close.BackgroundTransparency = 1
Close.BorderSizePixel = 0
Close.Position = UDim2.new(0.955061018, 0, -0.00211034436, 0)
Close.Size = UDim2.new(0, 12, 0, 13)
Close.Modal = true
Close.Font = Enum.Font.SourceSans
Close.Text = "X"
Close.TextColor3 = Color3.new(0.65098, 0, 0)
Close.TextSize = 14
Close.MouseButton1Down:connect(function()
Main.Visible = false
OpenFrame.Visible = true
end)

game:GetService("StarterGui"):SetCore("SendNotification", {
Title = "Auto-Farm";
Text = "Enjoy The GUI!";
Icon = "rbxassetid://3095216816";
Duration = 5;
})

--https://v3rmillion.net/showthread.php?tid=836023&highlight=Farmtown credits:
SernyPoptart
--Dunt mess dis down here >:C

--// VARS //--


local PlayerData = require(game.ReplicatedStorage:WaitForChild("PlayerData"))
local plr = game:GetService("Players").LocalPlayer
local selling = false

--// FUNCTIONS //--


local function fS(func, ...)
assert(type(func) == "function")
local args = {...}
local bindable = Instance.new("BindableEvent")
bindable.Event:Connect(
function()
func(unpack(args))
end
)
bindable:Fire()
bindable:Destroy()
end
local function isInTable(table, toFind)
assert(type(table) == "table")
assert(type(toFind) == "string")
local found = false
for _, v in pairs(table) do
if v == toFind then
found = true
break
end
end
return found
end

local function sellCrops()


local data = PlayerData.get()
if data.weight > 0 then
selling = not selling
if not _G.OutBox then
plr.Character:MoveTo(Vector3.new(52, 5, -453))
wait(3)
end
for crop, _ in pairs(_G.crops) do
local cropType = crop
local quantity = 0
if cropType and cropType ~= "none" then
quantity = data.crops[cropType]
end
game.ReplicatedStorage.UseMarket:FireServer("SellCrop", cropType, quantity,
_G.OutBox)
game.ReplicatedStorage.CropSold:Fire(cropType, quantity, _G.OutBox)
end
selling = not selling
end
end

local function useWell()


if selling then
return
end

local well = _G.farm:FindFirstChild("Well")

local wellPos = well.PrimaryPart.Position


local plrPos = plr.Character.PrimaryPart.Position

local distance = (plrPos - wellPos).magnitude

if distance >= 14 then


plr.Character:MoveTo(wellPos)
wait(.6)
end
end

local function createFarmPlots()


_G.plots = {}
_G.farm = nil
_G.plotSize = 0
for i = 1, 8 do
if
workspace:FindFirstChild("Farm" .. i) and workspace["Farm" ..
i]:FindFirstChild("Owner") and
workspace["Farm" .. i].Owner.Value == plr
then
_G.farm = workspace["Farm" .. i]
end
end

for i = 1, 6 do
if _G.farm:FindFirstChild("Plot" .. i) then
table.insert(_G.plots, _G.farm["Plot" .. i])
_G.plotSize = _G.plotSize + #_G.farm["Plot" .. i]:GetChildren()
end
end

_G.farm.ChildAdded:Connect(function()
_G.plots = {}

for i = 1, 6 do
if _G.farm:FindFirstChild("Plot" .. i) then
table.insert(_G.plots, _G.farm["Plot" .. i])
_G.plotSize = _G.plotSize + #_G.farm["Plot" .. i]:GetChildren()
end
end
end)
end

local function harvest(v)


local data = PlayerData.get()
local type = v.CropType.Value
local stage = v.CropStage.Value
local reqStage = _G.crops[type]

if type == "Corn" and reqStage - 1 == stage and data.seeds[type] < _G.plotSize


then
game.ReplicatedStorage.ManipulateCrop:FireServer(v, "Harvest")
elseif reqStage == stage then
game.ReplicatedStorage.ManipulateCrop:FireServer(v, "Harvest")
end
end

local function plant(v)


local data = PlayerData.get()
if data.seeds[_G.seed] then
game.ReplicatedStorage.ManipulateCrop:FireServer(v, "PlantSeed", _G.seed)
end
end

local function water(v)


game.ReplicatedStorage.ManipulateCrop:FireServer(v, "Water")
useWell()
game.ReplicatedStorage.UseItem:FireServer(_G.farm:FindFirstChild("Well"))
end

local function plotFarm(plot)


assert(typeof(plot) == "Instance")
for _, v in pairs(plot:GetChildren()) do
if v.Name ~= "Camera1" and v.Name ~= "Camera2" and v.Name ~= "Plot" and v.Name
~= "HasGreenhouse" then
if v.CropType.Value ~= "none" then
harvest(v)
else
plant(v)
end
if v.WaterContent.Value <= 2 then
water(v)
end
end
end
end

local function autoFarm()


while _G.KillSwitch do
wait(5)
if _G.farming then
for _, plot in pairs(_G.plots) do
fS(sellCrops)
fS(plotFarm, plot)
end
end
end
end

if _G.farm == nil then


createFarmPlots()
end

if not _G.crops or not isInTable(_G.crops, "Hay") then


_G.crops = {}
for _, v in
pairs(game:GetService("ReplicatedStorage").Assets.Farming.Crops:GetChildren()) do
_G.crops[v.Name] = #v:GetChildren()
end
end

--// INIT //--


_G.KillSwitch = false -- Just in case if someone execute everything
wait(6)
_G.KillSwitch = true -- instead of just changing the _G vars up there

autoFarm()

You might also like