Advertisement
Guest User

Vickymariposa1

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