Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local player = Players.LocalPlayer
- local Tycoonx = player:WaitForChild("TycoonPath").Value
- local TycoonWorkspace = game.Workspace:WaitForChild("Tycoons"):WaitForChild(Tycoonx)
- local TycoonReplicatedStorage = game:GetService("ReplicatedStorage"):WaitForChild("Tycoons"):WaitForChild(Tycoonx)
- local mouse = player:GetMouse()
- local TreesFolder = TycoonWorkspace.TreesFolder
- local FruitsGrowData = require(TycoonReplicatedStorage:WaitForChild("FruitsGrowData"))
- local Functions = require(game:GetService("ReplicatedStorage"):WaitForChild("ReusableFunctions"))
- local Inventory = require(TycoonReplicatedStorage:WaitForChild("Inventory"))
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local ServerCollectFruits = ReplicatedStorage:WaitForChild("ServerCollectFruits")
- local ServerFruitsGrowing = ReplicatedStorage:WaitForChild("ServerFruitsGrowing")
- local CollectFruitsScriptEvent = ReplicatedStorage:WaitForChild("CollectFruitsScriptEvent")
- local CollectFruitsScriptEvent2 = ReplicatedStorage:WaitForChild("CollectFruitsScriptEvent2")
- local function CollectFruits(Tree)
- local isDebounced = false
- local debounceTime = 0.05
- if Tree:FindFirstChild("Value") and not isDebounced then
- if not Inventory[Tree.Value] then
- Inventory.AddCrop(tostring(Tree.Value.Value), 0)
- end
- Inventory.AddCrop(tostring(Tree.Value.Value), 1)
- isDebounced = true
- ServerCollectFruits:FireServer(Tree,Tree.Value , Tree.Value.Value)
- wait(debounceTime)
- isDebounced = false
- else
- print("No crop to harvest.")
- end
- end
- local function GrowFruits(targetName)
- if FruitsGrowData[targetName] ~= "Growing" then
- local Tree = TycoonWorkspace:WaitForChild("TreesFolder"):WaitForChild(tostring(targetName))
- ServerFruitsGrowing:FireServer(Tree)
- end
- end
- local isDebounced = false
- local debounceTime = 2
- local maxdistance = 2
- mouse.Button1Up:Connect(function()
- if not isDebounced then
- local object = mouse.Target
- local objectPosition = object.Position
- local distance = (objectPosition - mouse.Hit.Position).Magnitude
- if distance < maxdistance then
- local target1 = mouse.Target
- local target = target1.Parent
- if target and target:IsA("Part") and target.Parent == TreesFolder then
- if FruitsGrowData[target.Name] == "Complete" or FruitsGrowData[target.Name] == nil then
- if FruitsGrowData[target.Name] == nil then
- CollectFruits(target)
- FruitsGrowData.AddPlot(target.Name, "Growing")
- print(FruitsGrowData)
- CollectFruitsScriptEvent:FireServer(240, target.Name)
- end
- if FruitsGrowData[target.Name] == "Complete" then
- CollectFruits(target)
- FruitsGrowData.ChangeStatus(target.Name, "Growing")
- print(FruitsGrowData)
- CollectFruitsScriptEvent:FireServer(240, target.Name)
- end
- --local time = tick()
- --local dif
- --local bre = 0
- --while true do
- --wait(1)
- --dif = tick() - time
- --if dif > 60 then
- -- FruitsGrowData.ChangeStatus(target.Name, "Complete") -- changes the status of the crop after 10 s
- -- print(FruitsGrowData)
- -- print(target.Name, "Target.Name")
- -- GrowFruits(target)
- -- isDebounced = true
- -- wait(debounceTime)
- -- isDebounced = false
- -- bre = 1
- -- return
- --end
- --if bre == 1 then
- -- break
- --end
- --end
- else
- print("it still growing")
- end
- end
- end
- end
- end)
- CollectFruitsScriptEvent2.OnClientEvent:Connect(function(targetName)
- if TycoonWorkspace:WaitForChild("TreesFolder"):WaitForChild(tostring(targetName)).Parent == TreesFolder then
- FruitsGrowData.ChangeStatus(targetName, "Complete") -- changes the status of the crop after 10 s
- GrowFruits(targetName)
- isDebounced = true
- wait(debounceTime)
- isDebounced = false
- end
- end)
- local Players = game:GetService("Players")
- local player = Players.LocalPlayer
- local Tycoonx = player:WaitForChild("TycoonPath").Value
- local TycoonWorkspace = game.Workspace:WaitForChild("Tycoons"):WaitForChild(Tycoonx)
- local TycoonReplicatedStorage = game:GetService("ReplicatedStorage"):WaitForChild("Tycoons"):WaitForChild(Tycoonx)
- local mouse = player:GetMouse()
- local plotsFolder = TycoonWorkspace.plotsFolder
- local PlotsGrowData = require(TycoonReplicatedStorage:WaitForChild("PlotsGrowData"))
- local Inventory = require(TycoonReplicatedStorage:WaitForChild("Inventory"))
- local SeedInventory = require(TycoonReplicatedStorage:WaitForChild("SeedInventory"))
- local Functions = require(game:GetService("ReplicatedStorage"):WaitForChild("ReusableFunctions"))
- local PlayerGui = player:WaitForChild("PlayerGui")
- local SeedInventoryFrame = PlayerGui:WaitForChild("SeedInventoryScreenGui"):WaitForChild("SeedInventoryFrame")
- local SeedInventoryExitButton = PlayerGui:WaitForChild("SeedInventoryScreenGui"):WaitForChild("SeedInventoryExitButton")
- -- Connect the planting logic to a remote event
- -- local remoteEvent = game:WaitForChild("AddItemEvent")
- local UserInputService = game:GetService("UserInputService")
- local PlantsGrowingTime = require(game:GetService("ReplicatedStorage"):WaitForChild("PlantsGrowingTime"))
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local ServerPlantsGrowing1 = ReplicatedStorage:WaitForChild("ServerPlantsGrowing1")
- local ServerPlantsGrowing2 = ReplicatedStorage:WaitForChild("ServerPlantsGrowing2")
- local ServerHarvest = ReplicatedStorage:WaitForChild("ServerHarvest")
- local PlantingHarvestingScriptEvent = ReplicatedStorage:WaitForChild("PlantingHarvestingScriptEvent")
- local PlantingHarvestingScriptEvent2 = ReplicatedStorage:WaitForChild("PlantingHarvestingScriptEvent2")
- local function createSeedButton(seedName, Number)
- local seedImage = Instance.new("ImageButton")
- seedImage.Name = seedName
- seedImage.Image = game:GetService("ReplicatedStorage"):WaitForChild("SeedsImage"):WaitForChild(seedName).Texture
- seedImage.Size = UDim2.new(1, 1, 0, 30)
- seedImage.Parent = SeedInventoryFrame
- local seedButton = Instance.new("TextLabel")
- seedButton.Name = seedName
- seedButton.Text = seedName.." ×"..Number
- seedButton.Size = UDim2.new(1, 1, 0, 30)
- seedButton.Position = seedImage.Position + UDim2.new(0, 0, 1, 0)
- seedButton.Parent = SeedInventoryFrame:WaitForChild(seedName)
- end
- local function ShowSeedsInventoryfunction()
- SeedInventoryFrame:ClearAllChildren()
- local uiGridLayout = Instance.new("UIGridLayout")
- uiGridLayout.CellPadding = UDim2.new(0, 10, 0, 40) -- Adjust padding as needed
- uiGridLayout.CellSize = UDim2.new(0, 100, 0, 100) -- Adjust cell size as needed
- uiGridLayout.FillDirection = Enum.FillDirection.Horizontal -- Choose either Vertical or Horizontal
- uiGridLayout.HorizontalAlignment = Enum.HorizontalAlignment.Left -- Adjust as needed
- uiGridLayout.SortOrder = Enum.SortOrder.LayoutOrder
- uiGridLayout.Parent = SeedInventoryFrame
- local UIPadding = Instance.new("UIPadding")
- UIPadding.PaddingLeft = UDim.new(0, 10)
- UIPadding.PaddingTop = UDim.new(0, 10)
- UIPadding.Parent = SeedInventoryFrame
- -- Parent the UIGridLayout to the Frame
- local seedList = Functions.deepCopy(SeedInventory)
- seedList.AddSeed = nil
- seedList.deleteSeed = nil
- for seedName, Number in pairs(seedList) do
- createSeedButton(seedName, Number)
- end
- -- SeedInventoryFrame.Visible = not SeedInventoryFrame.Visible
- -- SeedInventoryExitButton.Visible = not SeedInventoryExitButton.Visible
- SeedInventoryFrame.Visible = true
- SeedInventoryExitButton.Visible = true
- print(SeedInventory)
- end
- local planted = false
- local function plantCrop(plot)
- print(#SeedInventory, "seedinventory")
- if plot:FindFirstChild("Crop") == nil and Functions.CountDictionnary(SeedInventory) ~= 2 then
- ShowSeedsInventoryfunction()
- local i = 0
- local b = 0
- local a = 0
- while wait(0.001) do
- i=i+1
- if i > 250 then
- return
- end
- local ListOfButton = SeedInventoryFrame:GetChildren()
- table.remove(ListOfButton, 1)
- table.remove(ListOfButton, 1)
Advertisement
Add Comment
Please, Sign In to add comment