loldezpasteas2

Untitled

May 13th, 2018
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.31 KB | None | 0 0
  1. --]]
  2.  
  3. local Players = game.Players
  4. local Player = Players['LocalPlayer']
  5.  
  6. local Character = Player.Character or Player.CharacterAdded:wait()
  7. local HRP = Character['HumanoidRootPart']
  8. local Stat = workspace.Stats[Player.Name]
  9.  
  10. local DE = game.ReplicatedStorage.DataEvent
  11. local UE = Player.PlayerGui.MainGUI.Scripts.Inventory.UpdateEvent
  12.  
  13. local PP = workspace.PizzaPlanet
  14. local Stations = PP['BakerWorkstations']
  15. local Crates = PP['IngredientCrates']
  16. local Working, Stocking = true
  17.  
  18. Stat.Job:GetPropertyChangedSignal('Value'):Connect(function()
  19. if Stat.Job.Value == 'PizzaPlanetBaker' then Working = false
  20. else Working = true end
  21. end)
  22. if Stat.Job.Value == 'PizzaPlanetBaker' then Working = false end
  23.  
  24. local Orders = {
  25. Cheese = {true,true,true,false};
  26. Vegetable = {true,true,true,'Vegetable'};
  27. Ham = {true,true,true,'Ham'};
  28. Pepperoni = {true,true,true,'Pepperoni'}
  29. }
  30.  
  31. local CrateTP = Vector3.new(1163.78955, 13.5, 258.54892)
  32. local Positions = {
  33. Vector3.new(1173.34778, 13.5, 226.585571),
  34. Vector3.new(1172.8501, 13.5, 238.183029),
  35. Vector3.new(1173.20837, 13.5, 250.465881),
  36. Vector3.new(1173.47266, 13.5, 259.170837)
  37. }
  38.  
  39. local Part1 = coroutine.wrap(function()
  40. while wait() do
  41. for __, station in next, (Stations:GetChildren()) do
  42. if Working then break end
  43. local CT = station:FindFirstChild('CounterTop')
  44. if CT then CT.Parent = nil end
  45. station.InUse.Value = Player
  46.  
  47. local Pos = Positions[__]
  48. Character.Humanoid.WalkToPoint = Pos
  49. repeat wait() until (HRP.Position - Pos).magnitude < 2 or Working
  50. if Working then break end
  51.  
  52. local NI = station['OrderDisplay']['DisplayMain']:FindFirstChild('NoIngredients',true)
  53. if NI and NI.Visible and not Working then
  54. Stocking = true
  55. local Pos = CrateTP
  56. Character.Humanoid.WalkToPoint = Pos
  57. repeat wait() until (HRP.Position - Pos).magnitude < 2.75 or Working
  58. if Working then break end
  59.  
  60. local Crate = Crates.Crate;
  61. for __, cr in next, (Crates:GetChildren()) do
  62. if (cr.Position - HRP.Position).magnitude < (Crate.Position - HRP.Position).magnitude then
  63. Crate = cr
  64. end
  65. end
  66. Crate.Parent = game.Lighting.TempFolder
  67. wait()
  68. DE:FireServer({
  69. Object = game.Lighting.TempFolder.Crate,
  70. Type = 'TakeIngredientCrate'
  71. })
  72. Crate.Parent = Crates
  73. UE:Fire(Stat.EquippedItem)
  74. wait()
  75. end
  76.  
  77. local Pos = Positions[__]
  78. Character.Humanoid.WalkToPoint = Pos
  79. repeat wait() until (HRP.Position - Pos).magnitude < 2 or Working
  80. if Working then break end
  81. if Stocking then
  82. DE:FireServer({
  83. Workstation = station,
  84. Type = 'RestockIngredients'
  85. })
  86. end
  87. Stocking = false
  88. end
  89. for i = #Positions, 1, -1 do
  90. local station = Stations:GetChildren()[i]
  91. if Working then break end
  92. local CT = station:FindFirstChild('CounterTop')
  93. if CT then CT.Parent = nil end
  94. station.InUse.Value = Player
  95.  
  96. local Pos = Positions[i]
  97. Character.Humanoid.WalkToPoint = Pos
  98. repeat wait() until (HRP.Position - Pos).magnitude < 2 or Working
  99. if Working then break end
  100.  
  101. local NI = station['OrderDisplay']['DisplayMain']:FindFirstChild('NoIngredients',true)
  102. if NI and NI.Visible and not Working then
  103. Stocking = true
  104. local Pos = CrateTP
  105. Character.Humanoid.WalkToPoint = Pos
  106. repeat wait() until (HRP.Position - Pos).magnitude < 2.75 or Working
  107. if Working then break end
  108.  
  109. local Crate = Crates.Crate;
  110. for __, cr in next, (Crates:GetChildren()) do
  111. if (cr.Position - HRP.Position).magnitude < (Crate.Position - HRP.Position).magnitude then
  112. Crate = cr
  113. end
  114. end
  115. Crate.Parent = game.Lighting.TempFolder
  116. wait()
  117. DE:FireServer({
  118. Object = game.Lighting.TempFolder.Crate,
  119. Type = 'TakeIngredientCrate'
  120. })
  121. Crate.Parent = Crates
  122. UE:Fire(Stat.EquippedItem)
  123. wait()
  124. end
  125.  
  126. local Pos = Positions[i]
  127. Character.Humanoid.WalkToPoint = Pos
  128. repeat wait() until (HRP.Position - Pos).magnitude < 2 or Working
  129. if Working then break end
  130. if Stocking then
  131. DE:FireServer({
  132. Workstation = station,
  133. Type = 'RestockIngredients'
  134. })
  135. end
  136. Stocking = false
  137. end
  138. end
  139. end)
  140.  
  141. local Part2 = coroutine.wrap(function()
  142. while wait(1) do
  143. for __, station in next, (Stations:GetChildren()) do
  144. if Working or Stocking then break end
  145. local send = Orders[station.Order.Value]
  146. local count = station.Order.IngredientsLeft.Value
  147. DE:FireServer({
  148. Workstation = station,
  149. Type = 'UseWorkstation'
  150. })
  151.  
  152. if Working or Stocking then break end
  153. if count > 2 then count = count - 1 end
  154. for i = 1, count do
  155. DE:FireServer({
  156. Workstation = station,
  157. Type = 'UseWorkstation'
  158. })
  159. end
  160.  
  161. if Working or Stocking then break end
  162.  
  163. DE:FireServer({
  164. Order = send,
  165. Workstation = station,
  166. Type = 'FinishOrder'
  167. })
  168. UE:Fire(Stat.Job.ShiftEarnings)
  169. end
  170. end
  171. end)
  172.  
  173. Part1()
  174. Part2()
Add Comment
Please, Sign In to add comment