momo561

apply as scripter

Jul 25th, 2025 (edited)
23
0
2 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.14 KB | Source Code | 0 0
  1. local Players = game:GetService("Players")
  2. local player = Players.LocalPlayer
  3.  
  4.  
  5.  
  6.  
  7. local Tycoonx = player:WaitForChild("TycoonPath").Value
  8.  
  9. local TycoonWorkspace = game.Workspace:WaitForChild("Tycoons"):WaitForChild(Tycoonx)
  10. local TycoonReplicatedStorage = game:GetService("ReplicatedStorage"):WaitForChild("Tycoons"):WaitForChild(Tycoonx)
  11.  
  12. local mouse = player:GetMouse()
  13. local TreesFolder = TycoonWorkspace.TreesFolder
  14.  
  15. local FruitsGrowData = require(TycoonReplicatedStorage:WaitForChild("FruitsGrowData"))
  16.  
  17. local Functions = require(game:GetService("ReplicatedStorage"):WaitForChild("ReusableFunctions"))
  18.  
  19. local Inventory = require(TycoonReplicatedStorage:WaitForChild("Inventory"))
  20. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  21.  
  22. local ServerCollectFruits = ReplicatedStorage:WaitForChild("ServerCollectFruits")
  23. local ServerFruitsGrowing = ReplicatedStorage:WaitForChild("ServerFruitsGrowing")
  24.  
  25.  
  26. local CollectFruitsScriptEvent = ReplicatedStorage:WaitForChild("CollectFruitsScriptEvent")
  27. local CollectFruitsScriptEvent2 = ReplicatedStorage:WaitForChild("CollectFruitsScriptEvent2")
  28.  
  29.  
  30.  
  31. local function CollectFruits(Tree)
  32. local isDebounced = false
  33. local debounceTime = 0.05
  34.  
  35. if Tree:FindFirstChild("Value") and not isDebounced then
  36.  
  37.  
  38. if not Inventory[Tree.Value] then
  39. Inventory.AddCrop(tostring(Tree.Value.Value), 0)
  40.  
  41. end
  42. Inventory.AddCrop(tostring(Tree.Value.Value), 1)
  43.  
  44. isDebounced = true
  45.  
  46. ServerCollectFruits:FireServer(Tree,Tree.Value , Tree.Value.Value)
  47.  
  48. wait(debounceTime)
  49. isDebounced = false
  50.  
  51.  
  52.  
  53.  
  54. else
  55. print("No crop to harvest.")
  56. end
  57. end
  58.  
  59. local function GrowFruits(targetName)
  60. if FruitsGrowData[targetName] ~= "Growing" then
  61. local Tree = TycoonWorkspace:WaitForChild("TreesFolder"):WaitForChild(tostring(targetName))
  62. ServerFruitsGrowing:FireServer(Tree)
  63. end
  64.  
  65.  
  66.  
  67.  
  68. end
  69.  
  70.  
  71. local isDebounced = false
  72. local debounceTime = 2
  73. local maxdistance = 2
  74.  
  75.  
  76. mouse.Button1Up:Connect(function()
  77. if not isDebounced then
  78.  
  79. local object = mouse.Target
  80. local objectPosition = object.Position
  81. local distance = (objectPosition - mouse.Hit.Position).Magnitude
  82. if distance < maxdistance then
  83.  
  84.  
  85. local target1 = mouse.Target
  86. local target = target1.Parent
  87.  
  88.  
  89. if target and target:IsA("Part") and target.Parent == TreesFolder then
  90. if FruitsGrowData[target.Name] == "Complete" or FruitsGrowData[target.Name] == nil then
  91. if FruitsGrowData[target.Name] == nil then
  92. CollectFruits(target)
  93. FruitsGrowData.AddPlot(target.Name, "Growing")
  94. print(FruitsGrowData)
  95. CollectFruitsScriptEvent:FireServer(240, target.Name)
  96.  
  97. end
  98. if FruitsGrowData[target.Name] == "Complete" then
  99. CollectFruits(target)
  100. FruitsGrowData.ChangeStatus(target.Name, "Growing")
  101. print(FruitsGrowData)
  102. CollectFruitsScriptEvent:FireServer(240, target.Name)
  103.  
  104. end
  105.  
  106.  
  107.  
  108. --local time = tick()
  109. --local dif
  110.  
  111. --local bre = 0
  112. --while true do
  113. --wait(1)
  114. --dif = tick() - time
  115. --if dif > 60 then
  116.  
  117. -- FruitsGrowData.ChangeStatus(target.Name, "Complete") -- changes the status of the crop after 10 s
  118. -- print(FruitsGrowData)
  119. -- print(target.Name, "Target.Name")
  120.  
  121. -- GrowFruits(target)
  122. -- isDebounced = true
  123. -- wait(debounceTime)
  124. -- isDebounced = false
  125. -- bre = 1
  126.  
  127. -- return
  128.  
  129. --end
  130. --if bre == 1 then
  131.  
  132. -- break
  133. --end
  134. --end
  135.  
  136. else
  137.  
  138. print("it still growing")
  139.  
  140.  
  141. end
  142. end
  143. end
  144. end
  145. end)
  146.  
  147. CollectFruitsScriptEvent2.OnClientEvent:Connect(function(targetName)
  148. if TycoonWorkspace:WaitForChild("TreesFolder"):WaitForChild(tostring(targetName)).Parent == TreesFolder then
  149. FruitsGrowData.ChangeStatus(targetName, "Complete") -- changes the status of the crop after 10 s
  150.  
  151. GrowFruits(targetName)
  152. isDebounced = true
  153. wait(debounceTime)
  154. isDebounced = false
  155. end
  156. end)
  157.  
  158. local Players = game:GetService("Players")
  159.  
  160. local player = Players.LocalPlayer
  161.  
  162.  
  163.  
  164.  
  165. local Tycoonx = player:WaitForChild("TycoonPath").Value
  166.  
  167. local TycoonWorkspace = game.Workspace:WaitForChild("Tycoons"):WaitForChild(Tycoonx)
  168. local TycoonReplicatedStorage = game:GetService("ReplicatedStorage"):WaitForChild("Tycoons"):WaitForChild(Tycoonx)
  169.  
  170.  
  171. local mouse = player:GetMouse()
  172. local plotsFolder = TycoonWorkspace.plotsFolder
  173.  
  174. local PlotsGrowData = require(TycoonReplicatedStorage:WaitForChild("PlotsGrowData"))
  175.  
  176. local Inventory = require(TycoonReplicatedStorage:WaitForChild("Inventory"))
  177. local SeedInventory = require(TycoonReplicatedStorage:WaitForChild("SeedInventory"))
  178. local Functions = require(game:GetService("ReplicatedStorage"):WaitForChild("ReusableFunctions"))
  179.  
  180. local PlayerGui = player:WaitForChild("PlayerGui")
  181. local SeedInventoryFrame = PlayerGui:WaitForChild("SeedInventoryScreenGui"):WaitForChild("SeedInventoryFrame")
  182. local SeedInventoryExitButton = PlayerGui:WaitForChild("SeedInventoryScreenGui"):WaitForChild("SeedInventoryExitButton")
  183.  
  184. -- Connect the planting logic to a remote event
  185. -- local remoteEvent = game:WaitForChild("AddItemEvent")
  186.  
  187. local UserInputService = game:GetService("UserInputService")
  188.  
  189.  
  190. local PlantsGrowingTime = require(game:GetService("ReplicatedStorage"):WaitForChild("PlantsGrowingTime"))
  191.  
  192. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  193.  
  194. local ServerPlantsGrowing1 = ReplicatedStorage:WaitForChild("ServerPlantsGrowing1")
  195. local ServerPlantsGrowing2 = ReplicatedStorage:WaitForChild("ServerPlantsGrowing2")
  196. local ServerHarvest = ReplicatedStorage:WaitForChild("ServerHarvest")
  197. local PlantingHarvestingScriptEvent = ReplicatedStorage:WaitForChild("PlantingHarvestingScriptEvent")
  198. local PlantingHarvestingScriptEvent2 = ReplicatedStorage:WaitForChild("PlantingHarvestingScriptEvent2")
  199.  
  200.  
  201.  
  202.  
  203. local function createSeedButton(seedName, Number)
  204. local seedImage = Instance.new("ImageButton")
  205. seedImage.Name = seedName
  206. seedImage.Image = game:GetService("ReplicatedStorage"):WaitForChild("SeedsImage"):WaitForChild(seedName).Texture
  207. seedImage.Size = UDim2.new(1, 1, 0, 30)
  208. seedImage.Parent = SeedInventoryFrame
  209. local seedButton = Instance.new("TextLabel")
  210. seedButton.Name = seedName
  211. seedButton.Text = seedName.." ×"..Number
  212. seedButton.Size = UDim2.new(1, 1, 0, 30)
  213. seedButton.Position = seedImage.Position + UDim2.new(0, 0, 1, 0)
  214.  
  215. seedButton.Parent = SeedInventoryFrame:WaitForChild(seedName)
  216.  
  217. end
  218.  
  219.  
  220.  
  221. local function ShowSeedsInventoryfunction()
  222. SeedInventoryFrame:ClearAllChildren()
  223. local uiGridLayout = Instance.new("UIGridLayout")
  224. uiGridLayout.CellPadding = UDim2.new(0, 10, 0, 40) -- Adjust padding as needed
  225. uiGridLayout.CellSize = UDim2.new(0, 100, 0, 100) -- Adjust cell size as needed
  226. uiGridLayout.FillDirection = Enum.FillDirection.Horizontal -- Choose either Vertical or Horizontal
  227. uiGridLayout.HorizontalAlignment = Enum.HorizontalAlignment.Left -- Adjust as needed
  228. uiGridLayout.SortOrder = Enum.SortOrder.LayoutOrder
  229. uiGridLayout.Parent = SeedInventoryFrame
  230.  
  231. local UIPadding = Instance.new("UIPadding")
  232. UIPadding.PaddingLeft = UDim.new(0, 10)
  233. UIPadding.PaddingTop = UDim.new(0, 10)
  234. UIPadding.Parent = SeedInventoryFrame
  235.  
  236. -- Parent the UIGridLayout to the Frame
  237. local seedList = Functions.deepCopy(SeedInventory)
  238.  
  239. seedList.AddSeed = nil
  240. seedList.deleteSeed = nil
  241.  
  242. for seedName, Number in pairs(seedList) do
  243. createSeedButton(seedName, Number)
  244. end
  245. -- SeedInventoryFrame.Visible = not SeedInventoryFrame.Visible
  246. -- SeedInventoryExitButton.Visible = not SeedInventoryExitButton.Visible
  247. SeedInventoryFrame.Visible = true
  248. SeedInventoryExitButton.Visible = true
  249.  
  250.  
  251. print(SeedInventory)
  252. end
  253.  
  254.  
  255. local planted = false
  256.  
  257.  
  258. local function plantCrop(plot)
  259. print(#SeedInventory, "seedinventory")
  260. if plot:FindFirstChild("Crop") == nil and Functions.CountDictionnary(SeedInventory) ~= 2 then
  261. ShowSeedsInventoryfunction()
  262. local i = 0
  263. local b = 0
  264. local a = 0
  265. while wait(0.001) do
  266. i=i+1
  267. if i > 250 then
  268. return
  269. end
  270.  
  271.  
  272.  
  273.  
  274. local ListOfButton = SeedInventoryFrame:GetChildren()
  275. table.remove(ListOfButton, 1)
  276. table.remove(ListOfButton, 1)
Advertisement
Add Comment
Please, Sign In to add comment