Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.12 KB | None | 0 0
  1. function onMouseClickFieldSection1()
  2.     print("Clicked on Field Section 1")
  3.     local part = clickDetectorFieldSection1.Parent
  4.    
  5.     if(cropFullyGrown.FieldSection1 == true) then
  6.         inventory.Cotton = inventory.Cotton + 1
  7.         updateInventoryGUI()
  8.         part["Cotton5"]:Destroy()
  9.         part.Transparency = 0.5
  10.         cropFullyGrown.FieldSection1 = false
  11.        
  12.        
  13.     else
  14.         if(inventory.Gold >= 10)
  15.         then
  16.            
  17.             clickDetectorFieldSection1.MaxActivationDistance = 0
  18.             inventory.Gold = inventory.Gold - 10
  19.             updateInventoryGUI()
  20.            
  21.             part.Transparency = 1
  22.            
  23.             if(cropFullyGrown.FieldSection1 == false) then
  24.                
  25.                 for index = 1, #cottonArray do --#cottonArray = size of cottonArray
  26.                     local partToClone = cottonArray[index]
  27.                     local clone = partToClone:Clone()
  28.                     clone.Parent = part
  29.                    
  30.                     local startCFrame = CFrame.new(part.Position)
  31.                     clone:setPrimaryPartCFrame(startCFrame)
  32.                    
  33.                     wait(2)
  34.                    
  35.                     if(index ~=6) then
  36.                         clone:Destroy()
  37.                     else
  38.                         cropFullyGrown.FieldSection1 = true
  39.                     end
  40.                 end
  41.                
  42.             end
  43.            
  44.             clickDetectorFieldSection1.MaxActivationDistance = 32  
  45.     end
  46.     end
  47. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement