Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. function RF.OnServerInvoke(player, request, data)
  2. local id = player.UserId
  3. local farm = workspace.Farms:FindFirstChild(player.Name)
  4. local land = farm.Land
  5. if request == "placement" then
  6. local object, slot = data[1], data[2]
  7.  
  8. local result = dataCache[id].grid:AddSlot(slot, object)
  9. if result then
  10. local objectClone = RS.Land:FindFirstChild(object):Clone()
  11.  
  12. if objectClone:FindFirstChild("HarvestTime") then
  13. local timeStage2 = objectModule[object].HarvestTimeAmount * (3/4)
  14. local timeStage3 = objectModule[object].HarvestTimeAmount * (1/4)
  15. local harvestTime = objectClone:FindFirstChild("HarvestTime")
  16. objectClone.Parent = land
  17. objectClone.Name = slot
  18. objectClone:SetPrimaryPartCFrame(CFrame.new(land:FindFirstChild(slot).PrimaryPart.Position))
  19. land:FindFirstChild(slot):Destroy()
  20.  
  21. spawn(function()
  22. if harvestTime then
  23. harvestTime.Value = objectModule[object].HarvestTimeAmount
  24. end
  25. while harvestTime do
  26. if harvestTime.Value == 0 then
  27. growCrop(objectClone:FindFirstChild("Stage3"), objectClone:FindFirstChild("Stage4"), false)
  28. objectClone.PrimaryPart:FindFirstChild("TimeGui").Time.Text = "Harvest"
  29. break
  30. elseif harvestTime.Value == timeStage2 then
  31. growCrop(objectClone:FindFirstChild("Stage1"), objectClone:FindFirstChild("Stage2"), false)
  32. elseif harvestTime.Value == timeStage3 then
  33. growCrop(objectClone:FindFirstChild("Stage2"), objectClone:FindFirstChild("Stage3"), false)
  34. end
  35. wait(1)
  36. if objectClone.PrimaryPart then
  37. if objectClone.PrimaryPart:FindFirstChild("TimeGui") then
  38. harvestTime.Value = harvestTime.Value - 1
  39. objectClone.PrimaryPart:FindFirstChild("TimeGui").Time.Text = timeFormat(harvestTime.Value)
  40. end
  41. end
  42. end
  43. end)
  44. else
  45. objectClone.Parent = workspace.Farms:FindFirstChild(player.Name).Land
  46. objectClone.Name = slot
  47. objectClone:SetPrimaryPartCFrame(CFrame.new(land:FindFirstChild(slot).PrimaryPart.Position))
  48. workspace.Farms:FindFirstChild(player.Name).Land:FindFirstChild(slot):Destroy()
  49. end
  50.  
  51. local grid = dataCache[player.UserId].grid
  52. printGrid(grid.board)
  53. return true
  54. else
  55. return false
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement