Advertisement
suramraja1

awdwa

Jul 1st, 2025 (edited)
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 43.96 KB | None | 0 0
  1. -- SERVICES & MODULES
  2. local Players = game:GetService("Players")
  3. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  4. local UserInputService = game:GetService("UserInputService")
  5. local player = Players.LocalPlayer
  6.  
  7. local GetFarm = require(ReplicatedStorage.Modules.GetFarm)
  8. local MutationHandler = require(ReplicatedStorage.Modules:WaitForChild("MutationHandler"))
  9.  
  10. -- ✅ FRUIT LOG SYSTEM
  11. local fruitLog = {}
  12. local maxLogEntries = 200
  13. local lastKnownFruits = {} -- Track existing fruits to detect spawns/deletions
  14. local logGui = nil
  15.  
  16. -- Helper function for mutation priority
  17. local function getMutationPriority(mutation)
  18.     local priorityMap = {
  19.         ["Moonlit"] = 6,
  20.         ["Choc"] = 5,
  21.         ["Shocked"] = 4,
  22.         ["Frozen"] = 3,
  23.         ["Chilled"] = 2,
  24.         ["Wet"] = 1,
  25.         ["None"] = 0
  26.     }
  27.    
  28.     -- Count mutations and assign a priority
  29.     if mutation == "None" then
  30.         return 0
  31.     end
  32.    
  33.     -- If it contains multiple mutations, count them
  34.     local count = 0
  35.     for w in mutation:gmatch("([^•]+)") do -- Changed to match bullet separator
  36.         count = count + 1
  37.     end
  38.    
  39.     -- Multiple mutations always have highest priority
  40.     if count > 1 then
  41.         return 100 + count
  42.     end
  43.    
  44.     -- Single mutation - look up its priority
  45.     for mutName, priority in pairs(priorityMap) do
  46.         if mutation:find(mutName) then
  47.             return priority
  48.         end
  49.     end
  50.    
  51.     return 0
  52. end
  53.  
  54. -- Helper function for variant priority
  55. local function getVariantPriority(variant)
  56.     local priorityMap = {
  57.         ["Rainbow"] = 3,
  58.         ["Gold"] = 2,
  59.         ["Normal"] = 1
  60.     }
  61.    
  62.     return priorityMap[variant] or 0
  63. end
  64.  
  65. -- GUI SETUP
  66. local playerGui = player:WaitForChild("PlayerGui")
  67.  
  68. -- Check if GUI already exists and remove it
  69. local existingGui = playerGui:FindFirstChild("FruitListGui")
  70. if existingGui then
  71.     existingGui:Destroy()
  72. end
  73.  
  74. -- State variables
  75. local currentSortColumn = "Fruit Name" -- Default sort by name
  76. local currentSortDir = "asc" -- Default ascending
  77. local allFruitsData = {} -- Will store all fruits data for sorting
  78. local isMinimized = false -- Track minimize state
  79. local originalSize -- Store original size when minimizing
  80.  
  81. local fruitListGui = Instance.new("ScreenGui")
  82. fruitListGui.Name = "FruitListGui"
  83. fruitListGui.ResetOnSpawn = false
  84. fruitListGui.Parent = playerGui
  85.  
  86. local mainFrame = Instance.new("Frame")
  87. mainFrame.Size = UDim2.new(0, 500, 0, 400)
  88. mainFrame.Position = UDim2.new(0.5, -250, 0.5, -200)
  89. mainFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
  90. mainFrame.BackgroundTransparency = 0.1
  91. mainFrame.Parent = fruitListGui
  92. mainFrame.Active = true
  93.  
  94. -- Store original size for minimizing
  95. originalSize = mainFrame.Size
  96.  
  97. -- Add rounded corners to main frame
  98. local mainCorner = Instance.new("UICorner")
  99. mainCorner.CornerRadius = UDim.new(0, 8)
  100. mainCorner.Parent = mainFrame
  101.  
  102. -- Title bar
  103. local titleBar = Instance.new("Frame")
  104. titleBar.Name = "TitleBar"
  105. titleBar.Size = UDim2.new(1, 0, 0, 30)
  106. titleBar.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
  107. titleBar.BorderSizePixel = 0
  108. titleBar.Parent = mainFrame
  109.  
  110. -- Add rounded corners to title bar (top corners only)
  111. local titleCorner = Instance.new("UICorner")
  112. titleCorner.CornerRadius = UDim.new(0, 8)
  113. titleCorner.Parent = titleBar
  114.  
  115. -- Make sure the title bar only rounds the top corners
  116. local bottomFrame = Instance.new("Frame")
  117. bottomFrame.Size = UDim2.new(1, 0, 0.5, 0)
  118. bottomFrame.Position = UDim2.new(0, 0, 0.5, 0)
  119. bottomFrame.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
  120. bottomFrame.BorderSizePixel = 0
  121. bottomFrame.Parent = titleBar
  122.  
  123. local titleText = Instance.new("TextLabel")
  124. titleText.Name = "Title"
  125. titleText.Size = UDim2.new(1, -60, 1, 0)
  126. titleText.BackgroundTransparency = 1
  127. titleText.Text = "Farm Fruit List"
  128. titleText.Font = Enum.Font.SourceSansBold
  129. titleText.TextColor3 = Color3.fromRGB(255, 255, 255)
  130. titleText.TextSize = 18
  131. titleText.Parent = titleBar
  132.  
  133. -- Close button
  134. local closeButton = Instance.new("TextButton")
  135. closeButton.Name = "CloseButton"
  136. closeButton.Size = UDim2.new(0, 30, 0, 30)
  137. closeButton.Position = UDim2.new(1, -30, 0, 0)
  138. closeButton.BackgroundColor3 = Color3.fromRGB(200, 60, 60)
  139. closeButton.Text = "X"
  140. closeButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  141. closeButton.TextSize = 18
  142. closeButton.Font = Enum.Font.SourceSansBold
  143. closeButton.Parent = titleBar
  144.  
  145. -- Add rounded corners to close button
  146. local closeCorner = Instance.new("UICorner")
  147. closeCorner.CornerRadius = UDim.new(0, 6)
  148. closeCorner.Parent = closeButton
  149.  
  150. -- Minimize button
  151. local minimizeButton = Instance.new("TextButton")
  152. minimizeButton.Name = "MinimizeButton"
  153. minimizeButton.Size = UDim2.new(0, 30, 0, 30)
  154. minimizeButton.Position = UDim2.new(1, -65, 0, 0)
  155. minimizeButton.BackgroundColor3 = Color3.fromRGB(60, 60, 200)
  156. minimizeButton.Text = "-"
  157. minimizeButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  158. minimizeButton.TextSize = 22
  159. minimizeButton.Font = Enum.Font.SourceSansBold
  160. minimizeButton.Parent = titleBar
  161.  
  162. -- Add rounded corners to minimize button
  163. local minimizeCorner = Instance.new("UICorner")
  164. minimizeCorner.CornerRadius = UDim.new(0, 6)
  165. minimizeCorner.Parent = minimizeButton
  166.  
  167. -- Function to toggle minimize state
  168. local function toggleMinimize()
  169.     isMinimized = not isMinimized
  170.    
  171.     if isMinimized then
  172.         -- Store current size before minimizing
  173.         originalSize = mainFrame.Size
  174.        
  175.         -- Minimize GUI - just show title bar
  176.         mainFrame.Size = UDim2.new(0, 300, 0, 30)
  177.         minimizeButton.Text = "+"
  178.        
  179.         -- Hide content
  180.         if mainFrame:FindFirstChild("HeaderFrame") then
  181.             mainFrame.HeaderFrame.Visible = false
  182.         end
  183.         if mainFrame:FindFirstChild("ScrollingFrame") then
  184.             mainFrame.ScrollingFrame.Visible = false
  185.         end
  186.         if mainFrame:FindFirstChild("ResizeHandle") then
  187.             mainFrame.ResizeHandle.Visible = false
  188.         end
  189.     else
  190.         -- Restore GUI to original size
  191.         mainFrame.Size = originalSize
  192.         minimizeButton.Text = "-"
  193.        
  194.         -- Show content
  195.         if mainFrame:FindFirstChild("HeaderFrame") then
  196.             mainFrame.HeaderFrame.Visible = true
  197.         end
  198.         if mainFrame:FindFirstChild("ScrollingFrame") then
  199.             mainFrame.ScrollingFrame.Visible = true
  200.         end
  201.         if mainFrame:FindFirstChild("ResizeHandle") then
  202.             mainFrame.ResizeHandle.Visible = true
  203.         end
  204.     end
  205. end
  206.  
  207. -- Connect minimize button
  208. minimizeButton.MouseButton1Click:Connect(toggleMinimize)
  209.  
  210. -- Add keyboard shortcut (Left Ctrl) to toggle minimize
  211. UserInputService.InputBegan:Connect(function(input)
  212.     if input.KeyCode == Enum.KeyCode.LeftControl then
  213.         toggleMinimize()
  214.     end
  215. end)
  216.  
  217. -- Resize Handle
  218. local resizeHandle = Instance.new("Frame")
  219. resizeHandle.Size = UDim2.new(0, 24, 0, 24)
  220. resizeHandle.Position = UDim2.new(1, -24, 1, -24)
  221. resizeHandle.BackgroundColor3 = Color3.fromRGB(80, 80, 80)
  222. resizeHandle.BorderSizePixel = 0
  223. resizeHandle.Parent = mainFrame
  224. resizeHandle.Name = "ResizeHandle"
  225. resizeHandle.ZIndex = 10
  226.  
  227. local resizeCorner = Instance.new("UICorner")
  228. resizeCorner.CornerRadius = UDim.new(0, 8)
  229. resizeCorner.Parent = resizeHandle
  230.  
  231. -- IMPROVED DRAGGING IMPLEMENTATION
  232. local dragging = false
  233. local dragInput
  234. local dragStart
  235. local startPos
  236. local lastMousePos
  237. local lastGoalPos
  238.  
  239. local function updateDrag(input)
  240.     if dragging then
  241.         local delta = input.Position - dragStart
  242.         local position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X,
  243.                                    startPos.Y.Scale, startPos.Y.Offset + delta.Y)
  244.        
  245.         -- Use a smoother movement with lerping
  246.         game:GetService("RunService").RenderStepped:Wait()
  247.         mainFrame.Position = position
  248.     end
  249. end
  250.  
  251. titleBar.InputBegan:Connect(function(input)
  252.     if input.UserInputType == Enum.UserInputType.MouseButton1 or
  253.        input.UserInputType == Enum.UserInputType.Touch then
  254.         dragging = true
  255.         dragStart = input.Position
  256.         startPos = mainFrame.Position
  257.         lastMousePos = Vector2.new(input.Position.X, input.Position.Y)
  258.        
  259.         -- Continue tracking even if mouse leaves the titleBar
  260.         input.Changed:Connect(function()
  261.             if input.UserInputState == Enum.UserInputState.End then
  262.                 dragging = false
  263.             end
  264.         end)
  265.     end
  266. end)
  267.  
  268. titleBar.InputChanged:Connect(function(input)
  269.     if input.UserInputType == Enum.UserInputType.MouseMovement or
  270.        input.UserInputType == Enum.UserInputType.Touch then
  271.         dragInput = input
  272.     end
  273. end)
  274.  
  275. UserInputService.InputChanged:Connect(function(input)
  276.     if input == dragInput and dragging then
  277.         updateDrag(input)
  278.     end
  279. end)
  280.  
  281. -- Resize Script
  282. local draggingResize = false
  283. local resizeStart
  284. local startSize
  285.  
  286. resizeHandle.InputBegan:Connect(function(input)
  287.     if input.UserInputType == Enum.UserInputType.MouseButton1 or
  288.        input.UserInputType == Enum.UserInputType.Touch then
  289.         draggingResize = true
  290.         resizeStart = input.Position
  291.         startSize = mainFrame.Size
  292.        
  293.         -- Track input end even outside the resize handle
  294.         input.Changed:Connect(function()
  295.             if input.UserInputState == Enum.UserInputState.End then
  296.                 draggingResize = false
  297.             end
  298.         end)
  299.     end
  300. end)
  301.  
  302. UserInputService.InputChanged:Connect(function(input)
  303.     if draggingResize and (input.UserInputType == Enum.UserInputType.MouseMovement or
  304.                           input.UserInputType == Enum.UserInputType.Touch) then
  305.         local delta = input.Position - resizeStart
  306.         local newWidth = math.max(400, startSize.X.Offset + delta.X)
  307.         local newHeight = math.max(300, startSize.Y.Offset + delta.Y)
  308.         mainFrame.Size = UDim2.new(0, newWidth, 0, newHeight)
  309.        
  310.         -- Store new size for when un-minimizing
  311.         originalSize = mainFrame.Size
  312.        
  313.         -- Recalculate scrolling frame size when resizing
  314.         local headerHeight = 30 -- title bar height
  315.         if mainFrame:FindFirstChild("HeaderFrame") and mainFrame:FindFirstChild("ScrollingFrame") then
  316.             mainFrame.ScrollingFrame.Size = UDim2.new(1, -20, 1, -(headerHeight + mainFrame.HeaderFrame.Size.Y.Offset + 20))
  317.         end
  318.     end
  319. end)
  320.  
  321. -- Close button logic
  322. closeButton.MouseButton1Click:Connect(function()
  323.     fruitListGui:Destroy()
  324. end)
  325.  
  326. -- Header Frame for column titles
  327. local headerFrame = Instance.new("Frame")
  328. headerFrame.Name = "HeaderFrame"
  329. headerFrame.Size = UDim2.new(1, -20, 0, 35)
  330. headerFrame.Position = UDim2.new(0, 10, 0, 40)
  331. headerFrame.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
  332. headerFrame.BackgroundTransparency = 0.5
  333. headerFrame.Parent = mainFrame
  334.  
  335. -- Add rounded corners to header frame
  336. local headerCorner = Instance.new("UICorner")
  337. headerCorner.CornerRadius = UDim.new(0, 6)
  338. headerCorner.Parent = headerFrame
  339.  
  340. -- Column Headers - SIMPLIFIED: only 4 columns now
  341. local columns = {"Fruit Name", "Variant", "Weight (kg)", "Mutations"}
  342. local columnWidths = {0.22, 0.18, 0.18, 0.42}  -- Give more space to mutations column
  343. local sortButtons = {}
  344.  
  345. -- Scrolling Frame for fruit list
  346. local scrollingFrame = Instance.new("ScrollingFrame")
  347. scrollingFrame.Name = "ScrollingFrame"
  348. scrollingFrame.Size = UDim2.new(1, -20, 1, -85)
  349. scrollingFrame.Position = UDim2.new(0, 10, 0, 85)
  350. scrollingFrame.BackgroundTransparency = 0.9
  351. scrollingFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
  352. scrollingFrame.BorderSizePixel = 0
  353. scrollingFrame.ScrollBarThickness = 8
  354. scrollingFrame.Parent = mainFrame
  355.  
  356. -- Refresh Button
  357. local refreshButton = Instance.new("TextButton")
  358. refreshButton.Name = "RefreshButton"
  359. refreshButton.Size = UDim2.new(0, 100, 0, 25)
  360. refreshButton.Position = UDim2.new(0, 10, 0, 3)
  361. refreshButton.BackgroundColor3 = Color3.fromRGB(60, 120, 60)
  362. refreshButton.Text = "Refresh"
  363. refreshButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  364. refreshButton.TextSize = 16
  365. refreshButton.Font = Enum.Font.SourceSansBold
  366. refreshButton.Parent = titleBar
  367.  
  368. -- Create a UICorner for the refresh button
  369. local refreshCorner = Instance.new("UICorner")
  370. refreshCorner.CornerRadius = UDim.new(0, 4)
  371. refreshCorner.Parent = refreshButton
  372.  
  373. -- Status label (for minimize tooltip)
  374. local statusLabel = Instance.new("TextLabel")
  375. statusLabel.Name = "StatusLabel"
  376. statusLabel.Size = UDim2.new(0, 200, 0, 20)
  377. statusLabel.Position = UDim2.new(0.5, -100, 0, -25)
  378. statusLabel.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
  379. statusLabel.BackgroundTransparency = 0.2
  380. statusLabel.Text = "Press Left Ctrl to minimize"
  381. statusLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  382. statusLabel.TextSize = 14
  383. statusLabel.Font = Enum.Font.SourceSans
  384. statusLabel.Visible = false
  385. statusLabel.Parent = mainFrame
  386.  
  387. -- Add rounded corners to status label
  388. local statusCorner = Instance.new("UICorner")
  389. statusCorner.CornerRadius = UDim.new(0, 4)
  390. statusCorner.Parent = statusLabel
  391.  
  392. -- Show tooltip when hovering minimize button
  393. minimizeButton.MouseEnter:Connect(function()
  394.     statusLabel.Visible = true
  395. end)
  396.  
  397. minimizeButton.MouseLeave:Connect(function()
  398.     statusLabel.Visible = false
  399. end)
  400.  
  401. -- Function declaration for refreshFruitList (will be defined later)
  402. local refreshFruitList
  403.  
  404. -- Function to create sorted fruit list
  405. local function createSortedFruitList()
  406.     -- Clear existing list
  407.     for _, child in pairs(scrollingFrame:GetChildren()) do
  408.         if child:IsA("Frame") then
  409.             child:Destroy()
  410.         end
  411.     end
  412.    
  413.     -- Sort the fruits data based on current sort column and direction
  414.     table.sort(allFruitsData, function(a, b)
  415.         local aValue, bValue
  416.        
  417.         if currentSortColumn == "Fruit Name" then
  418.             aValue = a.name:lower()
  419.             bValue = b.name:lower()
  420.            
  421.         elseif currentSortColumn == "Variant" then
  422.             -- Sort by variant priority
  423.             aValue = getVariantPriority(a.variant)
  424.             bValue = getVariantPriority(b.variant)
  425.            
  426.         elseif currentSortColumn == "Mutations" then
  427.             -- Sort by mutation priority
  428.             aValue = getMutationPriority(a.mutations)
  429.             bValue = getMutationPriority(b.mutations)
  430.            
  431.         elseif currentSortColumn == "Weight (kg)" then
  432.             -- Use the raw numeric weight value instead of the string
  433.             aValue = a.weightNum or 0
  434.             bValue = b.weightNum or 0
  435.         else
  436.             return false
  437.         end
  438.        
  439.         if currentSortDir == "asc" then
  440.             return aValue < bValue
  441.         else
  442.             return aValue > bValue
  443.         end
  444.     end)
  445.    
  446.     -- Update sort button appearance
  447.     for colName, button in pairs(sortButtons) do
  448.         if colName == currentSortColumn then
  449.             button.Text = currentSortDir == "asc" and "▲" or "▼"
  450.             button.TextColor3 = Color3.fromRGB(255, 255, 100) -- Highlight active sort
  451.         else
  452.             button.Text = "◆"
  453.             button.TextColor3 = Color3.fromRGB(150, 150, 150) -- Dim inactive sorts
  454.         end
  455.     end
  456.    
  457.     -- Remote for collecting fruit
  458.     local PickupEvent = ReplicatedStorage:WaitForChild("GameEvents"):WaitForChild("Pickup")
  459.    
  460.     local rowHeight = 50 -- Increased height for better mutation display
  461.     for i, fruitData in ipairs(allFruitsData) do
  462.         -- Create row frame
  463.         local rowFrame = Instance.new("Frame")
  464.         rowFrame.Name = "Row_" .. i
  465.         rowFrame.Size = UDim2.new(1, 0, 0, rowHeight)
  466.         rowFrame.Position = UDim2.new(0, 0, 0, (i-1) * rowHeight)
  467.         rowFrame.BackgroundColor3 = i % 2 == 0 and Color3.fromRGB(40, 40, 40) or Color3.fromRGB(35, 35, 35)
  468.         rowFrame.BackgroundTransparency = 0.3
  469.         rowFrame.Parent = scrollingFrame
  470.        
  471.         -- Add hover effect
  472.         rowFrame.InputBegan:Connect(function(input)
  473.             if input.UserInputType == Enum.UserInputType.MouseMovement then
  474.                 rowFrame.BackgroundTransparency = 0.1
  475.             end
  476.         end)
  477.        
  478.         rowFrame.InputEnded:Connect(function(input)
  479.             if input.UserInputType == Enum.UserInputType.MouseMovement then
  480.                 rowFrame.BackgroundTransparency = 0.3
  481.             end
  482.         end)
  483.        
  484.         -- Create columns in the row
  485.         local currentX = 0
  486.         local columnValues = {fruitData.name, fruitData.variant, fruitData.weight, fruitData.mutations}
  487.        
  488.         -- Add collect button
  489.         local collectButton = Instance.new("TextButton")
  490.         collectButton.Name = "CollectButton"
  491.         collectButton.Size = UDim2.new(0, 70, 0, 25)
  492.         collectButton.Position = UDim2.new(1, -75, 0, 12.5) -- Right side of row, centered vertically
  493.         collectButton.BackgroundColor3 = Color3.fromRGB(60, 180, 80) -- Green
  494.         collectButton.Text = "Collect"
  495.         collectButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  496.         collectButton.TextSize = 14
  497.         collectButton.Font = Enum.Font.SourceSansBold
  498.         collectButton.Parent = rowFrame
  499.        
  500.         -- Add rounded corners to collect button
  501.         local collectCorner = Instance.new("UICorner")
  502.         collectCorner.CornerRadius = UDim.new(0, 4)
  503.         collectCorner.Parent = collectButton
  504.        
  505.         -- Store the fruit model in the button for reference
  506.         collectButton:SetAttribute("FruitModel", fruitData.model:GetFullName())
  507.        
  508.         -- Collect button click handler
  509.         collectButton.MouseButton1Click:Connect(function()
  510.             -- Show collecting status
  511.             local originalText = collectButton.Text
  512.             local originalColor = collectButton.BackgroundColor3
  513.             collectButton.Text = "..."
  514.             collectButton.BackgroundColor3 = Color3.fromRGB(150, 150, 150)
  515.            
  516.             -- Fire the remote to collect the fruit
  517.             local success, error = pcall(function()
  518.                 if fruitData.model and fruitData.model:IsA("Model") then
  519.                     -- Fire the pickup event to collect the fruit
  520.                     PickupEvent:FireServer(fruitData.model)
  521.                     task.wait(0.1) -- Small delay
  522.                    
  523.                     -- Track whether collection was successful
  524.                     local startTime = tick()
  525.                     local collected = false
  526.                    
  527.                     -- Check if fruit still exists after a brief delay
  528.                     task.wait(0.3)
  529.                     if not fruitData.model or not fruitData.model.Parent then
  530.                         -- Successfully collected
  531.                         collectButton.Text = "✓"
  532.                         collectButton.BackgroundColor3 = Color3.fromRGB(40, 180, 40)
  533.                         addToFruitLog("COLLECTED", fruitData.name, fruitData.variant, fruitData.weight, fruitData.mutations, fruitData.treeName)
  534.                        
  535.                         -- Disable the button
  536.                         collectButton.AutoButtonColor = false
  537.                         collectButton.Active = false
  538.                     else
  539.                         -- Failed to collect
  540.                         collectButton.Text = "Retry"
  541.                         collectButton.BackgroundColor3 = Color3.fromRGB(180, 100, 100)
  542.                     end
  543.                 else
  544.                     -- Fruit no longer exists
  545.                     collectButton.Text = "Gone"
  546.                     collectButton.BackgroundColor3 = Color3.fromRGB(150, 150, 150)
  547.                     collectButton.AutoButtonColor = false
  548.                 end
  549.             end)
  550.            
  551.             if not success then
  552.                 -- Error occurred
  553.                 collectButton.Text = "Error"
  554.                 collectButton.BackgroundColor3 = Color3.fromRGB(180, 60, 60)
  555.                 print("❌ Failed to collect fruit:", error)
  556.                
  557.                 -- Reset after delay
  558.                 task.delay(1.5, function()
  559.                     collectButton.Text = originalText
  560.                     collectButton.BackgroundColor3 = originalColor
  561.                 end)
  562.             end
  563.         end)
  564.        
  565.         -- Add hover effect to collect button
  566.         collectButton.MouseEnter:Connect(function()
  567.             if collectButton.Active ~= false then
  568.                 collectButton.BackgroundColor3 = Color3.fromRGB(80, 200, 100)
  569.             end
  570.         end)
  571.        
  572.         collectButton.MouseLeave:Connect(function()
  573.             if collectButton.Active ~= false then
  574.                 collectButton.BackgroundColor3 = Color3.fromRGB(60, 180, 80)
  575.             end
  576.         end)
  577.        
  578.         for j, columnValue in ipairs(columnValues) do
  579.             local cell = Instance.new("TextLabel")
  580.             cell.Name = "Column" .. j
  581.             cell.Size = UDim2.new(columnWidths[j], -10, 1, 0)
  582.             cell.Position = UDim2.new(currentX, 5, 0, 0)
  583.             cell.BackgroundTransparency = 1
  584.             cell.Font = Enum.Font.SourceSans
  585.             cell.TextColor3 = Color3.fromRGB(255, 255, 255)
  586.             cell.Text = tostring(columnValue)
  587.             cell.TextXAlignment = Enum.TextXAlignment.Left
  588.             cell.TextWrapped = true
  589.             cell.TextYAlignment = Enum.TextYAlignment.Top
  590.            
  591.             -- Special handling for mutations column (column 4)
  592.             if j == 4 then
  593.                 cell.TextSize = 14 -- Slightly smaller for more text
  594.                 cell.Font = Enum.Font.SourceSans
  595.                 -- Make sure mutations are fully visible
  596.                 if #tostring(columnValue) > 20 then
  597.                     cell.TextScaled = false -- Don't scale down, just wrap
  598.                 end
  599.                
  600.                 -- Make room for collect button
  601.                 cell.Size = UDim2.new(columnWidths[j] - 0.15, -10, 1, 0)
  602.             else
  603.                 cell.TextSize = 16
  604.                 cell.TextYAlignment = Enum.TextYAlignment.Center
  605.             end
  606.            
  607.             cell.Parent = rowFrame
  608.            
  609.             currentX = currentX + columnWidths[j]
  610.         end
  611.     end
  612.    
  613.     -- Update scrolling frame content size
  614.     scrollingFrame.CanvasSize = UDim2.new(0, 0, 0, #allFruitsData * rowHeight)
  615.    
  616.     -- Update counter
  617.     titleText.Text = "Farm Fruit List - " .. #allFruitsData .. " Fruits"
  618. end
  619.  
  620. -- Column Headers
  621. local currentX = 0
  622. for i, columnName in ipairs(columns) do
  623.     local headerContainer = Instance.new("Frame")
  624.     headerContainer.Name = columnName:gsub(" ", "") .. "HeaderContainer"
  625.     headerContainer.Size = UDim2.new(columnWidths[i], 0, 1, 0)
  626.     headerContainer.Position = UDim2.new(currentX, 0, 0, 0)
  627.     headerContainer.BackgroundTransparency = 1
  628.     headerContainer.Parent = headerFrame
  629.    
  630.     local columnHeader = Instance.new("TextLabel")
  631.     columnHeader.Name = columnName:gsub(" ", "") .. "Header"
  632.     columnHeader.Size = UDim2.new(1, -25, 1, 0) -- Make room for sort button
  633.     columnHeader.Position = UDim2.new(0, 5, 0, 0)
  634.     columnHeader.BackgroundTransparency = 1
  635.     columnHeader.Font = Enum.Font.SourceSansBold
  636.     columnHeader.TextColor3 = Color3.fromRGB(255, 255, 255)
  637.     columnHeader.TextSize = 18
  638.     columnHeader.Text = columnName
  639.     columnHeader.TextXAlignment = Enum.TextXAlignment.Left
  640.     columnHeader.Parent = headerContainer
  641.    
  642.     -- Add sort button
  643.     local sortButton = Instance.new("TextButton")
  644.     sortButton.Name = "SortButton"
  645.     sortButton.Size = UDim2.new(0, 20, 0, 20)
  646.     sortButton.Position = UDim2.new(1, -25, 0.5, -10)
  647.     sortButton.BackgroundTransparency = 0.8
  648.     sortButton.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
  649.     sortButton.Text = columnName == currentSortColumn and "▲" or "◆" -- Triangle up for current sort, diamond for others
  650.     sortButton.TextColor3 = columnName == currentSortColumn
  651.                          and Color3.fromRGB(255, 255, 100)
  652.                          or Color3.fromRGB(150, 150, 150)
  653.     sortButton.TextSize = 14
  654.     sortButton.Font = Enum.Font.SourceSansBold
  655.     sortButton.Parent = headerContainer
  656.    
  657.     -- Add rounded corners to sort button
  658.     local sortCorner = Instance.new("UICorner")
  659.     sortCorner.CornerRadius = UDim.new(0, 4)
  660.     sortCorner.Parent = sortButton
  661.    
  662.     -- Store the sort button for later reference
  663.     sortButtons[columnName] = sortButton
  664.    
  665.     -- Sort button click handler
  666.     sortButton.MouseButton1Click:Connect(function()
  667.         if currentSortColumn == columnName then
  668.             -- Toggle direction if same column
  669.             currentSortDir = currentSortDir == "asc" and "desc" or "asc"
  670.         else
  671.             -- New column, default directions
  672.             currentSortColumn = columnName
  673.            
  674.             -- Special case: weight should default to descending (high to low)
  675.             if columnName == "Weight (kg)" then
  676.                 currentSortDir = "desc"
  677.             else
  678.                 -- Variant and mutation have special logic so desc is actually "best first"
  679.                 if columnName == "Variant" or columnName == "Mutations" then
  680.                     currentSortDir = "desc" -- Rainbow/Multiple mutations first
  681.                 else
  682.                     currentSortDir = "asc" -- A-Z for regular text
  683.                 end
  684.             end
  685.         end
  686.        
  687.         createSortedFruitList()
  688.     end)
  689.    
  690.     -- Add hover effect to sort button
  691.     sortButton.MouseEnter:Connect(function()
  692.         sortButton.BackgroundTransparency = 0.5
  693.     end)
  694.    
  695.     sortButton.MouseLeave:Connect(function()
  696.         sortButton.BackgroundTransparency = 0.8
  697.     end)
  698.    
  699.     currentX = currentX + columnWidths[i]
  700. end
  701.  
  702. -- Function to refresh the fruit list
  703. refreshFruitList = function()
  704.     -- Clear all fruit data
  705.     allFruitsData = {}
  706.    
  707.     -- Get player farm
  708.     local farm = GetFarm(player)
  709.     if not farm or not farm:FindFirstChild("Important") or not farm.Important:FindFirstChild("Plants_Physical") then
  710.         local errorLabel = Instance.new("TextLabel")
  711.         errorLabel.Size = UDim2.new(1, 0, 0, 30)
  712.         errorLabel.Position = UDim2.new(0, 0, 0, 0)
  713.         errorLabel.BackgroundTransparency = 1
  714.         errorLabel.TextColor3 = Color3.fromRGB(255, 100, 100)
  715.         errorLabel.Text = "Farm not found!"
  716.         errorLabel.Font = Enum.Font.SourceSansSemibold
  717.         errorLabel.TextSize = 18
  718.         errorLabel.Parent = scrollingFrame
  719.         return
  720.     end
  721.    
  722.     local plantsPhysical = farm.Important.Plants_Physical
  723.    
  724.     -- Loop through all tree types
  725.     for _, treeType in pairs(plantsPhysical:GetChildren()) do
  726.         local fruitsFolder = treeType:FindFirstChild("Fruits")
  727.         if fruitsFolder then
  728.             for _, fruitModel in pairs(fruitsFolder:GetChildren()) do
  729.                 if fruitModel:IsA("Model") then
  730.                     -- Get fruit attributes and properties
  731.                     local fruitName = fruitModel.Name
  732.                    
  733.                     -- Get variant (typically stored as a child)
  734.                     local variant = fruitModel:FindFirstChild("Variant")
  735.                     local variantText = variant and variant.Value or "Normal"
  736.                    
  737.                     -- Get weight
  738.                     local weight = fruitModel:FindFirstChild("Weight")
  739.                     local weightNum = weight and weight.Value or 0
  740.                     local weightValue = weight and string.format("%.2f kg", weightNum) or "? kg"
  741.                    
  742.                     -- Get mutations from attributes (using MutationHandler if available)
  743.                     local mutations = ""
  744.                     local success, mutationString = pcall(function()
  745.                         return MutationHandler:GetMutationsAsString(fruitModel) or ""
  746.                     end)
  747.                    
  748.                     if not success or mutationString == "" then
  749.                         -- Try checking attributes directly
  750.                         local mutationList = {}
  751.                         for attrName, value in pairs(fruitModel:GetAttributes()) do
  752.                             if value == true and typeof(value) == "boolean" then
  753.                                 -- Check only known mutation attributes
  754.                                 if attrName == "Shocked" or
  755.                                    attrName == "Frozen" or
  756.                                    attrName == "Wet" or
  757.                                    attrName == "Chilled" or
  758.                                    attrName == "Twisted" or
  759.                                    attrName == "Choc" or
  760.                                    attrName == "Burnt" or
  761.                                    attrName == "Moonlit" then
  762.                                    
  763.                                     table.insert(mutationList, attrName)
  764.                                 end
  765.                             end
  766.                         end
  767.                        
  768.                         if #mutationList > 0 then
  769.                             -- Sort mutations for consistent display
  770.                             table.sort(mutationList)
  771.                             mutations = table.concat(mutationList, " • ") -- Use bullet separator for better readability
  772.                         else
  773.                             mutations = "None"
  774.                         end
  775.                     else
  776.                         -- Format the mutation string for better readability
  777.                         if mutationString ~= "" then
  778.                             -- Replace commas with bullet points for better visual separation
  779.                             mutations = mutationString:gsub(", ", " • ")
  780.                         else
  781.                             mutations = "None"
  782.                         end
  783.                     end
  784.  
  785.                     -- Store fruit data for sorting
  786.                     table.insert(allFruitsData, {
  787.                         name = fruitName,
  788.                         variant = variantText,
  789.                         mutations = mutations,
  790.                         weight = weightValue,
  791.                         weightNum = weightNum, -- Store raw number for sorting
  792.                         model = fruitModel,
  793.                         treeName = treeType.Name
  794.                     })
  795.                 end
  796.             end
  797.         end
  798.     end
  799.    
  800.     -- Display sorted fruit list
  801.     createSortedFruitList()
  802. end
  803.  
  804. -- Connect the refresh button
  805. refreshButton.MouseButton1Click:Connect(refreshFruitList)
  806.  
  807. -- Handle refresh on unhide
  808. minimizeButton.MouseButton1Click:Connect(function()
  809.     if isMinimized then
  810.         -- Will refresh data when un-minimizing
  811.         task.delay(0.1, function()
  812.             refreshFruitList()
  813.         end)
  814.     end
  815. end)
  816.  
  817. -- ✅ FRUIT LOG FUNCTIONS
  818. local function addToFruitLog(action, fruitName, variant, weight, mutations, treeName)
  819.     local timestamp = os.date("%H:%M:%S")
  820.    
  821.     local logEntry = {
  822.         time = timestamp,
  823.         action = action, -- "SPAWNED" or "DELETED"
  824.         fruit = fruitName or "Unknown",
  825.         variant = variant or "Normal",
  826.         weight = weight or "Unknown",
  827.         mutations = mutations or "None",
  828.         tree = treeName or "Unknown"
  829.     }
  830.    
  831.     table.insert(fruitLog, 1, logEntry) -- Add to beginning
  832.    
  833.     -- Keep only last entries
  834.     if #fruitLog > maxLogEntries then
  835.         table.remove(fruitLog, maxLogEntries + 1)
  836.     end
  837.    
  838.     local actionEmoji = action == "SPAWNED" and "🌟" or "🗑️"
  839.     local mutText = mutations ~= "None" and " (" .. mutations .. ")" or ""
  840.     print(string.format("%s [%s] %s: %s - %s %s%s on %s", actionEmoji, timestamp, action, fruitName, weight, variant, mutText, treeName))
  841.    
  842.     -- Update log GUI if exists
  843.     if logGui then
  844.         updateFruitLogDisplay()
  845.     end
  846. end
  847.  
  848. -- ✅ MONITOR FRUIT CHANGES
  849. local function checkFruitChanges()
  850.     local currentFruits = {}
  851.    
  852.     -- Get current fruits on farm
  853.     local farm = GetFarm(player)
  854.     if farm and farm:FindFirstChild("Important") and farm.Important:FindFirstChild("Plants_Physical") then
  855.         local plantsPhysical = farm.Important.Plants_Physical
  856.        
  857.         -- Loop through all tree types
  858.         for _, treeType in pairs(plantsPhysical:GetChildren()) do
  859.             if treeType:IsA("Folder") or treeType:IsA("Model") then
  860.                 -- Check for Fruits folder in each tree type
  861.                 local fruitsFolder = treeType:FindFirstChild("Fruits")
  862.                 if fruitsFolder then
  863.                     for _, fruitModel in pairs(fruitsFolder:GetChildren()) do
  864.                         if fruitModel:IsA("Model") and fruitModel.Name ~= "Fruits" then
  865.                             -- Use a more reliable unique identifier
  866.                             local fruitId = treeType.Name .. "_" .. fruitModel.Name .. "_" .. tostring(fruitModel)
  867.                            
  868.                             -- Get fruit data
  869.                             local fruitName = fruitModel.Name
  870.                             local variant = fruitModel:FindFirstChild("Variant")
  871.                             local variantText = variant and variant.Value or "Normal"
  872.                             local weight = fruitModel:FindFirstChild("Weight")
  873.                             local weightValue = weight and string.format("%.2f kg", weight.Value) or "? kg"
  874.                            
  875.                             -- Get mutations using same method as main GUI
  876.                             local mutations = "None"
  877.                             local success, mutationString = pcall(function()
  878.                                 return MutationHandler:GetMutationsAsString(fruitModel) or ""
  879.                             end)
  880.                            
  881.                             if success and mutationString ~= "" then
  882.                                 mutations = mutationString:gsub(", ", " • ")
  883.                             else
  884.                                 -- Check attributes directly
  885.                                 local mutationList = {}
  886.                                 for attrName, value in pairs(fruitModel:GetAttributes()) do
  887.                                     if value == true and typeof(value) == "boolean" then
  888.                                         if attrName == "Shocked" or attrName == "Frozen" or
  889.                                            attrName == "Wet" or attrName == "Chilled" or
  890.                                            attrName == "Twisted" or attrName == "Choc" or
  891.                                            attrName == "Burnt" or attrName == "Moonlit" then
  892.                                             table.insert(mutationList, attrName)
  893.                                         end
  894.                                     end
  895.                                 end
  896.                                
  897.                                 if #mutationList > 0 then
  898.                                     table.sort(mutationList)
  899.                                     mutations = table.concat(mutationList, " • ")
  900.                                 end
  901.                             end
  902.                            
  903.                             currentFruits[fruitId] = {
  904.                                 name = fruitName,
  905.                                 variant = variantText,
  906.                                 weight = weightValue,
  907.                                 mutations = mutations,
  908.                                 tree = treeType.Name
  909.                             }
  910.                         end
  911.                     end
  912.                 end
  913.             end
  914.         end
  915.     end
  916.    
  917.     -- Compare with last known fruits to detect changes
  918.    
  919.     -- Check for new fruits (spawned)
  920.     for fruitId, fruitData in pairs(currentFruits) do
  921.         if not lastKnownFruits[fruitId] then
  922.             addToFruitLog("SPAWNED", fruitData.name, fruitData.variant, fruitData.weight, fruitData.mutations, fruitData.tree)
  923.         end
  924.     end
  925.    
  926.     -- Check for deleted fruits
  927.     for fruitId, fruitData in pairs(lastKnownFruits) do
  928.         if not currentFruits[fruitId] then
  929.             addToFruitLog("DELETED", fruitData.name, fruitData.variant, fruitData.weight, fruitData.mutations, fruitData.tree)
  930.         end
  931.     end
  932.    
  933.     -- Update known fruits
  934.     lastKnownFruits = currentFruits
  935. end
  936.  
  937. -- ✅ FRUIT LOG GUI
  938. local function createFruitLogGui()
  939.     local playerGui = player:WaitForChild("PlayerGui")
  940.    
  941.     -- Remove existing log GUI
  942.     if logGui then
  943.         logGui:Destroy()
  944.     end
  945.    
  946.     local screenGui = Instance.new("ScreenGui")
  947.     screenGui.Name = "FruitLogGui"
  948.     screenGui.ResetOnSpawn = false
  949.     screenGui.Parent = playerGui
  950.    
  951.     local frame = Instance.new("Frame")
  952.     frame.Size = UDim2.new(0, 600, 0, 400)
  953.     frame.Position = UDim2.new(0.5, -300, 0.5, -200)
  954.     frame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
  955.     frame.BackgroundTransparency = 0.1
  956.     frame.Parent = screenGui
  957.     frame.Active = true
  958.    
  959.     -- Add rounded corners
  960.     local frameCorner = Instance.new("UICorner")
  961.     frameCorner.CornerRadius = UDim.new(0, 8)
  962.     frameCorner.Parent = frame
  963.    
  964.     -- Title bar
  965.     local titleBar = Instance.new("Frame")
  966.     titleBar.Size = UDim2.new(1, 0, 0, 30)
  967.     titleBar.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
  968.     titleBar.BorderSizePixel = 0
  969.     titleBar.Parent = frame
  970.    
  971.     local titleCorner = Instance.new("UICorner")
  972.     titleCorner.CornerRadius = UDim.new(0, 8)
  973.     titleCorner.Parent = titleBar
  974.    
  975.     -- Bottom frame for title bar
  976.     local bottomFrame = Instance.new("Frame")
  977.     bottomFrame.Size = UDim2.new(1, 0, 0.5, 0)
  978.     bottomFrame.Position = UDim2.new(0, 0, 0.5, 0)
  979.     bottomFrame.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
  980.     bottomFrame.BorderSizePixel = 0
  981.     bottomFrame.Parent = titleBar
  982.    
  983.     local titleText = Instance.new("TextLabel")
  984.     titleText.Size = UDim2.new(1, -60, 1, 0)
  985.     titleText.BackgroundTransparency = 1
  986.     titleText.Text = "🍎 Fruit Spawn/Delete Log"
  987.     titleText.Font = Enum.Font.SourceSansBold
  988.     titleText.TextColor3 = Color3.fromRGB(255, 255, 255)
  989.     titleText.TextSize = 18
  990.     titleText.Parent = titleBar
  991.    
  992.     -- Close button
  993.     local closeButton = Instance.new("TextButton")
  994.     closeButton.Size = UDim2.new(0, 30, 0, 30)
  995.     closeButton.Position = UDim2.new(1, -30, 0, 0)
  996.     closeButton.BackgroundColor3 = Color3.fromRGB(200, 60, 60)
  997.     closeButton.Text = "X"
  998.     closeButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  999.     closeButton.TextSize = 18
  1000.     closeButton.Font = Enum.Font.SourceSansBold
  1001.     closeButton.Parent = titleBar
  1002.    
  1003.     local closeCorner = Instance.new("UICorner")
  1004.     closeCorner.CornerRadius = UDim.new(0, 6)
  1005.     closeCorner.Parent = closeButton
  1006.    
  1007.     closeButton.MouseButton1Click:Connect(function()
  1008.         screenGui:Destroy()
  1009.         logGui = nil
  1010.     end)
  1011.    
  1012.     -- Clear button
  1013.     local clearButton = Instance.new("TextButton")
  1014.     clearButton.Size = UDim2.new(0, 80, 0, 25)
  1015.     clearButton.Position = UDim2.new(0, 10, 0, 40)
  1016.     clearButton.BackgroundColor3 = Color3.fromRGB(100, 100, 100)
  1017.     clearButton.Text = "Clear Log"
  1018.     clearButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  1019.     clearButton.TextSize = 12
  1020.     clearButton.Font = Enum.Font.SourceSans
  1021.     clearButton.Parent = frame
  1022.    
  1023.     local clearCorner = Instance.new("UICorner")
  1024.     clearCorner.CornerRadius = UDim.new(0, 4)
  1025.     clearCorner.Parent = clearButton
  1026.    
  1027.     clearButton.MouseButton1Click:Connect(function()
  1028.         fruitLog = {}
  1029.         updateFruitLogDisplay()
  1030.     end)
  1031.    
  1032.     -- Scroll frame
  1033.     local scrollFrame = Instance.new("ScrollingFrame")
  1034.     scrollFrame.Name = "LogScrollFrame"
  1035.     scrollFrame.Size = UDim2.new(1, -20, 1, -75)
  1036.     scrollFrame.Position = UDim2.new(0, 10, 0, 70)
  1037.     scrollFrame.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
  1038.     scrollFrame.BackgroundTransparency = 0.2
  1039.     scrollFrame.ScrollBarThickness = 8
  1040.     scrollFrame.Parent = frame
  1041.    
  1042.     local scrollCorner = Instance.new("UICorner")
  1043.     scrollCorner.CornerRadius = UDim.new(0, 6)
  1044.     scrollCorner.Parent = scrollFrame
  1045.    
  1046.     logGui = screenGui
  1047.     return screenGui
  1048. end
  1049.  
  1050. -- ✅ UPDATE LOG DISPLAY
  1051. function updateFruitLogDisplay()
  1052.     if not logGui then return end
  1053.    
  1054.     local success, err = pcall(function()
  1055.         local scrollFrame = logGui.FruitLogGui.LogScrollFrame
  1056.        
  1057.         -- Clear existing entries
  1058.         for _, child in ipairs(scrollFrame:GetChildren()) do
  1059.             if child:IsA("Frame") then
  1060.                 child:Destroy()
  1061.             end
  1062.         end
  1063.        
  1064.         -- Update title with count
  1065.         local titleLabel = logGui.FruitLogGui.Frame.Frame.TextLabel
  1066.         if titleLabel then
  1067.             titleLabel.Text = "🍎 Fruit Log (" .. #fruitLog .. " entries)"
  1068.         end
  1069.        
  1070.         -- Add log entries
  1071.         local yOffset = 0
  1072.         for i, entry in ipairs(fruitLog) do
  1073.             local entryFrame = Instance.new("Frame")
  1074.             entryFrame.Size = UDim2.new(1, -10, 0, 30)
  1075.             entryFrame.Position = UDim2.new(0, 5, 0, yOffset)
  1076.             entryFrame.BackgroundColor3 = entry.action == "SPAWNED"
  1077.                                          and Color3.fromRGB(40, 60, 40)
  1078.                                          or Color3.fromRGB(60, 40, 40)
  1079.             entryFrame.BackgroundTransparency = 0.3
  1080.             entryFrame.Parent = scrollFrame
  1081.            
  1082.             local entryCorner = Instance.new("UICorner")
  1083.             entryCorner.CornerRadius = UDim.new(0, 4)
  1084.             entryCorner.Parent = entryFrame
  1085.            
  1086.             local entryLabel = Instance.new("TextLabel")
  1087.             entryLabel.Size = UDim2.new(1, -10, 1, 0)
  1088.             entryLabel.Position = UDim2.new(0, 5, 0, 0)
  1089.             entryLabel.BackgroundTransparency = 1
  1090.             entryLabel.Font = Enum.Font.SourceSans
  1091.             entryLabel.TextSize = 11
  1092.             entryLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  1093.             entryLabel.TextXAlignment = Enum.TextXAlignment.Left
  1094.             entryLabel.TextYAlignment = Enum.TextYAlignment.Center
  1095.             entryLabel.TextWrapped = true
  1096.            
  1097.             local actionEmoji = entry.action == "SPAWNED" and "🌟" or "🗑️"
  1098.             local mutText = entry.mutations ~= "None" and " (" .. entry.mutations .. ")" or ""
  1099.            
  1100.             entryLabel.Text = string.format("%s [%s] %s: %s - %s %s%s on %s",
  1101.                 actionEmoji, entry.time, entry.action, entry.fruit, entry.weight, entry.variant, mutText, entry.tree)
  1102.            
  1103.             entryLabel.Parent = entryFrame
  1104.             yOffset = yOffset + 35
  1105.         end
  1106.        
  1107.         scrollFrame.CanvasSize = UDim2.new(0, 0, 0, yOffset)
  1108.        
  1109.         -- Auto-scroll to bottom to see latest entries
  1110.         scrollFrame.CanvasPosition = Vector2.new(0, math.max(0, yOffset - scrollFrame.AbsoluteSize.Y))
  1111.     end)
  1112.    
  1113.     if not success then
  1114.         print("❌ Error updating fruit log display:", err)
  1115.     end
  1116. end
  1117.  
  1118. -- ✅ LOG BUTTON (Position next to refresh button)
  1119. local logButton = Instance.new("TextButton")
  1120. logButton.Name = "LogButton"
  1121. logButton.Size = UDim2.new(0, 80, 0, 25)
  1122. logButton.Position = UDim2.new(0, 115, 0, 3) -- Next to refresh button
  1123. logButton.BackgroundColor3 = Color3.fromRGB(60, 120, 60)
  1124. logButton.Text = "🍎 Log"
  1125. logButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  1126. logButton.TextSize = 14
  1127. logButton.Font = Enum.Font.SourceSansBold
  1128. logButton.Parent = titleBar
  1129.  
  1130. local logCorner = Instance.new("UICorner")
  1131. logCorner.CornerRadius = UDim.new(0, 4)
  1132. logCorner.Parent = logButton
  1133.  
  1134. logButton.MouseButton1Click:Connect(function()
  1135.     if not logGui then
  1136.         createFruitLogGui()
  1137.         updateFruitLogDisplay()
  1138.     else
  1139.         logGui:Destroy()
  1140.         logGui = nil
  1141.     end
  1142. end)
  1143.  
  1144. -- ✅ START FRUIT MONITORING
  1145. spawn(function()
  1146.     -- Initial setup - populate known fruits to avoid spam on first run
  1147.     task.wait(3) -- Wait for GUI to load
  1148.     pcall(checkFruitChanges) -- First scan to populate baseline
  1149.    
  1150.     print("🍎 Fruit monitoring started!")
  1151.    
  1152.     while true do
  1153.         task.wait(3) -- Check every 3 seconds
  1154.         local success, error = pcall(checkFruitChanges)
  1155.         if not success then
  1156.             print("❌ Fruit monitoring error:", error)
  1157.         end
  1158.     end
  1159. end)
  1160.  
  1161. -- Initial refresh
  1162. refreshFruitList()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement