Advertisement
HEHEJ

Untitled

Mar 29th, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.87 KB | None | 0 0
  1. local library = loadstring(game:HttpGet("https://pastebin.com/raw/CkyR8ePz", true))()
  2. local Farm = library:CreateWindow('Auto Farm')
  3. local player = game:GetService("Players").LocalPlayer
  4. local ffc = game.FindFirstChild
  5. local RNG = Random.new()
  6. local remoteKey
  7. local character,root
  8. local function FindFirstCustomer()
  9. local children = workspace.Customers:GetChildren()
  10. for i=1,#children do
  11. local c = children[i]
  12. if ffc(c,"Head") and ffc(c,"Humanoid") and c.Head.CFrame.Z<102 and (ffc(c.Head,"ChatBubble")==nil or ffc(c.Head.ChatBubble,"Bubble")==nil) and ((c.Humanoid.SeatPart and c.Humanoid.SeatPart.Anchored) or (c.Humanoid.SeatPart==nil and (c.Head.Velocity.Z^2)^.5<.0001)) then
  13. return c
  14. end
  15. end
  16. end
  17.  
  18. local boxPtick=0
  19. local boxDtick=0
  20.  
  21. local supplyCounts = {TomatoSauce=99,Cheese=99,Sausage=99,Pepperoni=99,Dough=99,Box=99,Dew=99}
  22. for name in pairs(supplyCounts) do
  23. local lbl = workspace.SupplyCounters[name=="Dew" and "CounterMountainDew" or "Counter"..name].a.SG.Counter
  24. supplyCounts[name]=tonumber(lbl.Text)
  25. lbl.Changed:Connect(function()
  26. supplyCounts[name]=tonumber(lbl.Text)
  27. end)
  28. end
  29.  
  30.  
  31. local function FindBoxes()
  32. local c,o,f
  33. local children = workspace.AllBox:GetChildren()
  34. for i=1,#children do
  35. local b = children[i]
  36. if ffc(b,"HasPizzaInside") or ffc(b,"Pizza") then
  37. if c==nil and b.Name=="BoxClosed" and b.Anchored==false and not b.HasPizzaInside.Value then
  38. c=b
  39. elseif o==nil and b.Name=="BoxOpen" and b.Anchored==false and not b.Pizza.Value then
  40. o=b
  41. elseif f==nil and (b.Name=="BoxOpen" and b.Pizza.Value) or (b.Name=="BoxClosed" and b.HasPizzaInside.Value) then
  42. f=b
  43. end
  44. if c and o and f then
  45. return c,o,f
  46. end
  47. end
  48. end
  49. return c,o,f
  50. end
  51. local function FindBoxingFoods()
  52. local p,d
  53. local children = workspace.BoxingRoom:GetChildren()
  54. for i=1,#children do
  55. local f = children[i]
  56. if not f.Anchored then
  57. if p==nil and f.Name=="Pizza" then
  58. p=f
  59. elseif d==nil and f.Name=="Dew" then
  60. d=f
  61. end
  62. if p and d then
  63. return p,d
  64. end
  65. end
  66. end
  67. return p,d
  68. end
  69.  
  70. local orderDict={["3540529228"]="Cheese",["3540530535"]="Sausage",["3540529917"]="Pepperoni",["2512571151"]="Dew",["2512441325"]="Dew"}
  71. local cookingDict = {Cheese=0,Sausage=0,Pepperoni=0,Dew=0}
  72. local cookPtick=0
  73. local cookDtick=0
  74. local cookWarned=false
  75. local boxerWarned=false
  76. local function getOrders()
  77. local orders={}
  78. local tempCookingDict = {}
  79. for i,v in pairs(cookingDict) do tempCookingDict[i]=v end
  80. local children = workspace.Orders:GetChildren()
  81. for i=1,#children do
  82. local o = orderDict[children[i].SG.ImageLabel.Image:match("%d+$")]
  83. if o then
  84. if tempCookingDict[o]>0 then
  85. --ignores oven pizzas, so new orders are priority
  86. tempCookingDict[o]=tempCookingDict[o]-1
  87. elseif (o=="Dew" and #workspace.AllMountainDew:GetChildren()>0) or (supplyCounts[o]>0 and supplyCounts.TomatoSauce>0 and supplyCounts.Cheese>0) then
  88. --need supplies
  89. orders[#orders+1]=o
  90. end
  91. end
  92. end
  93. return orders
  94. end
  95. local function FindFirstDew()
  96. local children = workspace.AllMountainDew:GetChildren()
  97. for i=1,#children do
  98. if not children[i].Anchored then
  99. return children[i]
  100. end
  101. end
  102. end
  103. local function FindDoughAndWithout(str)
  104. local goodraw,p,raw,trash
  105. local children = workspace.AllDough:GetChildren()
  106. for i = #children, 2, -1 do --shuffle
  107. local j = RNG:NextInteger(1, i)
  108. children[j], children[i] = children[i], children[j]
  109. end
  110. for i=1,#children do
  111. local d = children[i]
  112. if d.Anchored==false and #d:GetChildren()>9 then
  113. if d.IsBurned.Value or d.HasBugs.Value or d.Cold.Value or (d.BrickColor.Name=="Bright orange" and ffc(d,"XBillboard")) then
  114. if trash==nil and d.Position.Y > 0 then
  115. trash=d
  116. end
  117. elseif p==nil and d.BrickColor.Name=="Bright orange" then
  118. p=d
  119. elseif goodraw==nil and d.Position.X<55 and d.BrickColor.Name=="Brick yellow" and ((str and not ffc(d.SG.Frame,str)) or (str==nil and ffc(d.SG.Frame,"Sausage")==nil and ffc(d.SG.Frame,"Pepperoni")==nil)) then
  120. --prefers flat
  121. if d.Mesh.Scale.Y<1.1 then
  122. goodraw=d
  123. else
  124. raw=d
  125. end
  126. end
  127. if goodraw and p and trash then
  128. return goodraw,p,trash
  129. end
  130. end
  131. end
  132. return goodraw or raw,p,trash
  133. end
  134. local function getOvenNear(pos)
  135. local children = workspace.Ovens:GetChildren()
  136. for i=1,#children do
  137. if (children[i].Bottom.Position-pos).magnitude < 1.5 then
  138. return children[i]
  139. end
  140. end
  141. end
  142. local function getDoughNear(pos)
  143. local children = workspace.AllDough:GetChildren()
  144. for i=1,#children do
  145. if (children[i].Position-pos).magnitude < 1.5 then
  146. return children[i]
  147. end
  148. end
  149. end
  150. local function isFullyOpen(oven)
  151. return oven.IsOpen.Value==true and (oven.Door.Meter.RotVelocity.Z^2)^.5<.0001
  152. end
  153.  
  154. local bcolorToSupply = {["Dark orange"]="Sausage",["Bright blue"]="Pepperoni",["Bright yellow"]="Cheese",["Bright red"]="TomatoSauce",["Dark green"]="Dew",["Brick yellow"]="Dough",["Light stone grey"]="Box",["Really black"]="Dew"}
  155. local supplyButtons = {}
  156. for _,button in ipairs(workspace.SupplyButtons:GetChildren()) do
  157. supplyButtons[bcolorToSupply[button.Unpressed.BrickColor.Name]] = button.Unpressed
  158. end
  159.  
  160. local delTool
  161. local function FindFirstDeliveryTool()
  162. local t
  163. local children = workspace:GetChildren()
  164. for i=1,#children do
  165. local v = children[i]
  166. if v.ClassName=="Tool" and v.Name:match("^%u%d$") and ffc(v,"House") and ffc(v,"Handle") and ffc(v,"Order") and v.Order.Value:match("%a") then
  167. if ffc(v.Handle,"X10") then
  168. return v
  169. end
  170. t = v
  171. end
  172. end
  173. return t
  174. end
  175. local function getHousePart(address)
  176. local houses = workspace.Houses:GetChildren()
  177. for i=1,#houses do
  178. local h = houses[i]
  179. if ffc(h,"Address") and h.Address.Value==address and ffc(h,"Upgrades") and h.Upgrades:GetChildren()[1] and ffc(h.Upgrades:GetChildren()[1],"GivePizza") then
  180. return h.Upgrades:GetChildren()[1].GivePizza
  181. end
  182. end
  183. end
  184. local delTouched=false
  185. local function forgetDeliveryTool()
  186. if delTool then
  187. if delTool.Parent==player.Backpack then
  188. delTool.Parent = character
  189. end
  190. if delTool.Parent==character then
  191. wait(0.1)
  192. delTool.Parent = workspace
  193. wait(0.1)
  194. end
  195. end
  196. delTool=nil
  197. delTouched=false
  198. if ffc(character,"RightHand") and ffc(character.RightHand,"RightGrip") then
  199. character.RightHand.RightGrip:Destroy()
  200. end
  201. end
  202.  
  203. local function onCharacterAdded(char)
  204. if not char then return end
  205. character=char
  206. root = character:WaitForChild("HumanoidRootPart")
  207. character:WaitForChild("Humanoid"):GetPropertyChangedSignal("WalkSpeed"):Connect(function()
  208. if delTool then
  209. character.Humanoid.WalkSpeed=16
  210. end
  211. end)
  212. end
  213. onCharacterAdded(player.Character or player.CharacterAdded:Wait())
  214. player.CharacterAdded:Connect(onCharacterAdded)
  215.  
  216. local function simTouch(part)
  217. local oldcc = part.CanCollide
  218. local oldcf = part.CFrame
  219. part.CanCollide = false
  220. part.CFrame = root.CFrame
  221. delay(0.01,function()
  222. part.CFrame = oldcf
  223. part.CanCollide = oldcc
  224. end)
  225. end
  226. local doCashier = false
  227. local doCook = false
  228. local doBoxer = false
  229. local doSupplier = false
  230. local doDelivery = false
  231. Farm:Toggle('Cashier', {flag = "toggle1"}, function(toggled)
  232. doCashier = toggled;
  233. end)
  234.  
  235. Farm:Toggle('Cook', {flag = "toggle1"}, function(toggled)
  236. doCook = toggled;
  237. end)
  238.  
  239. Farm:Toggle('Delievery', {flag = "toggle1"}, function(toggled)
  240. doDelivery = toggled;
  241. end)
  242. Farm:Toggle('Boxer', {flag = "toggle1"}, function(toggled)
  243. doBoxer = toggled;
  244. end)
  245.  
  246. Farm:Toggle('Supplier', {flag = "toggle1"}, function(toggled)
  247. doSupplier = toggled;
  248. end)
  249.  
  250. local Tools = library:CreateWindow('Tools')
  251.  
  252. Tools:Button("Steal Manager Chair", function()
  253. --by sirelKilla (v3rm)
  254.  
  255. --vars
  256. local Players = game:GetService("Players")
  257. local player = Players.LocalPlayer
  258. local humanoid = player.Character.Humanoid
  259. local mteam = game:GetService("Teams").Manager
  260. local man = mteam:GetPlayers()[1]
  261. --deletes a glitchy chair in the office (optional)
  262. if workspace:FindFirstChild("ExtraChair") and workspace.ExtraChair:FindFirstChild("Seat") then
  263. workspace.ExtraChair.Seat:Destroy()
  264. end
  265.  
  266. if man then
  267. --check if he's respawning or sitting
  268. local htxt
  269. if man.Character==nil or man.Character:FindFirstChild("HumanoidRootPart")==nil or man.Character:FindFirstChild("Humanoid")==nil then
  270. htxt = "Failed because manager is respawning"
  271. end
  272. local target = man.Character.HumanoidRootPart
  273. if man.Character.Humanoid.Sit then
  274. htxt = "Failed because manager is sitting"
  275. end
  276. if htxt then
  277. local h = Instance.new("Hint",workspace)
  278. h.Text = htxt
  279. wait(3)
  280. h:Destroy()
  281. return
  282. end
  283. --get in a car
  284. if not workspace.Cars:IsAncestorOf(humanoid.SeatPart) then
  285. humanoid.Jump=true
  286. wait(0.1)
  287. for _,car in ipairs(workspace.Cars:GetChildren()) do
  288. if car:FindFirstChild("Driver") and car.Driver.Occupant==nil and car:FindFirstChild("Owner") and car.Owner.Value==nil then
  289. car.Driver:Sit(humanoid)
  290. wait(0.3)
  291. if humanoid.SeatPart then
  292. break
  293. end
  294. end
  295. end
  296. end
  297. local seat = humanoid.SeatPart
  298. local car = seat.Parent
  299. local returncf = CFrame.new(14,-4.5,21)*CFrame.Angles(0,math.pi/2,0)
  300. for j=1,4 do
  301. --attempt to sit manager
  302. seat.Anchored=false
  303. local e = 0
  304. while car.HoodSeat.Occupant==nil and mteam:GetPlayers()[1] and target.Parent and e<5 do
  305. local newpos = target.Position+Vector3.new(0,-3,0)+target.CFrame.lookVector*5.5+target.Velocity*.7
  306. local flatdir = (target.CFrame.lookVector*Vector3.new(1,0,1)).Unit --target's looking direction, flattened
  307. if not (flatdir.x < 2) then --inf
  308. flatdir = Vector3.new(1,0,0)
  309. end
  310. car:SetPrimaryPartCFrame(CFrame.new(newpos,newpos-flatdir))
  311. seat.Velocity=Vector3.new()
  312. local e2=0
  313. while car.HoodSeat.Occupant==nil and mteam:GetPlayers()[1] and target.Parent and e2<0.7 do
  314. e2=e2+wait()
  315. end
  316. e=e+e2
  317. end
  318. --attempt to move manager
  319. car:SetPrimaryPartCFrame(returncf)
  320. wait(.1)
  321. car:SetPrimaryPartCFrame(returncf)
  322. seat.Anchored=true
  323. e = 0
  324. while mteam:GetPlayers()[1] and target.Parent and e<1 do
  325. e=e+wait()
  326. end
  327. car.HoodSeat:ClearAllChildren() --unsits anyone
  328. e = 0
  329. while mteam:GetPlayers()[1] and target.Parent and e<0.5 do
  330. e=e+wait()
  331. end
  332. if mteam:GetPlayers()[1]==nil or target.Parent==nil then
  333. break
  334. end
  335. end
  336. --reset car
  337. seat.Anchored=false
  338. wait()
  339. car:SetPrimaryPartCFrame(CFrame.new(120,10,-75))
  340. wait()
  341. end
  342.  
  343. --become manager
  344. humanoid.Jump=true
  345. wait(0.1)
  346. pcall(function() workspace.ManagerChair.Seat:Sit(humanoid) end)
  347. wait(0.3)
  348. humanoid.Jump=true
  349. wait(0.1)
  350. player.Character.HumanoidRootPart.CFrame = player.Character.HumanoidRootPart.CFrame+Vector3.new(5,5,6)
  351. end)
  352.  
  353.  
  354.  
  355.  
  356. while true do
  357. wait(0.3)
  358. if doCashier then
  359. local c = FindFirstCustomer()
  360. if c then
  361. local rootMoved = false
  362. if (root.Position-Vector3.new(46.34, 3.80, 82.02)).magnitude>9 then rootMoved = true root.CFrame = CFrame.new(46.34, 3.80, 82.02) wait(.1) end
  363. workspace.GameService.OrderCompleted:FireServer(c, false, workspace.Register3)
  364. if rootMoved then wait(.1) end
  365. end
  366. end
  367. if doCook then
  368. local order = getOrders()[1]
  369. local topping
  370. if order=="Pepperoni" or order=="Sausage" then topping=order end
  371. local cookD = FindFirstDew()
  372. local raw,cookP,trash
  373. if topping then
  374. --pepperoni order avoids sausage dough and vice verca
  375. raw,cookP,trash = FindDoughAndWithout(topping=="Pepperoni" and "Sausage" or "Pepperoni")
  376. else
  377. raw,cookP,trash = FindDoughAndWithout()
  378. end
  379. local rootMoved = false
  380. local ovens = workspace.Ovens:GetChildren()
  381. for i = #ovens, 2, -1 do --shuffle
  382. local j = RNG:NextInteger(1, i)
  383. ovens[j], ovens[i] = ovens[i], ovens[j]
  384. end
  385. --move final pizza
  386. if cookP and tick()-cookPtick>0.8 then
  387. local oven = getOvenNear(cookP.Position)
  388. if oven==nil or oven.IsOpen.Value then
  389. cookPtick=tick()
  390. if (root.Position-Vector3.new(44.63, 6.60, 45.20)).magnitude>9 then rootMoved = true root.CFrame = CFrame.new(44.63, 6.60, 45.20) wait(.1) end
  391. workspace.GameService.UpdateObjectProperty:FireServer(true, cookP, "CFrame", CFrame.new(56,4.1,38), remoteKey)
  392. end
  393. end
  394. if order then
  395. if order=="Dew" and cookD and tick()-cookDtick>0.8 then
  396. --move dew if ordered
  397. cookDtick=tick()
  398. if (root.Position-Vector3.new(44.63, 6.60, 45.20)).magnitude>9 then rootMoved = true root.CFrame = CFrame.new(44.63, 6.60, 45.20) wait(.1) end
  399. workspace.GameService.UpdateObjectProperty:FireServer(true, cookD, "CFrame", CFrame.new(53,4.68,36.5), remoteKey)
  400. elseif order~="Dew" and raw and raw.Parent and supplyCounts[order]>0 and supplyCounts.TomatoSauce>0 and supplyCounts.Cheese>0 then
  401. --make pizza
  402. if raw.Mesh.Scale.Y>1.5 then
  403. if (root.Position-Vector3.new(44.63, 6.60, 45.20)).magnitude>9 then rootMoved = true root.CFrame = CFrame.new(44.63, 6.60, 45.20) wait(.1) end
  404. workspace.GameService.UpdateObjectProperty:FireServer(true, raw, "CFrame", CFrame.new(RNG:NextNumber(29.6,44.6),3.7,RNG:NextNumber(42.5,48.5)), remoteKey)
  405. wait()
  406. workspace.GameService.SquishDough:FireServer(raw)
  407. else
  408. --make sure it will have an oven
  409. local oven
  410. for _,o in ipairs(ovens) do
  411. if isFullyOpen(o) then
  412. local other = getDoughNear(o.Bottom.Position)
  413. if other==nil or not (other.BrickColor.Name=="Bright orange" and ffc(other.SG.Frame,"TomatoSauce") and ffc(other.SG.Frame,"MeltedCheese")) then
  414. if other then
  415. --replace mistaken dough
  416. if (root.Position-Vector3.new(44.63, 6.60, 45.20)).magnitude>9 then rootMoved = true root.CFrame = CFrame.new(44.63, 6.60, 45.20) wait(.1) end
  417. workspace.GameService.UpdateObjectProperty:FireServer(true, other, "CFrame", CFrame.new(RNG:NextNumber(29.6,44.6),3.7,RNG:NextNumber(42.5,48.5)), remoteKey)
  418. wait()
  419. end
  420. oven=o
  421. break
  422. end
  423. end
  424. end
  425. if oven and raw.Parent==workspace.AllDough then
  426. --make
  427. if (root.Position-Vector3.new(44.63, 6.60, 45.20)).magnitude>9 then rootMoved = true root.CFrame = CFrame.new(44.63, 6.60, 45.20) wait(.1) end
  428. workspace.GameService.AddIngredientToPizza:FireServer(raw,"TomatoSauce")
  429. workspace.GameService.AddIngredientToPizza:FireServer(raw,"Cheese")
  430. workspace.GameService.AddIngredientToPizza:FireServer(raw,topping)
  431. workspace.GameService.UpdateObjectProperty:FireServer(true, raw, "CFrame", oven.Bottom.CFrame+Vector3.new(0,0.7,0), remoteKey)
  432. oven.Door.ClickDetector.Detector:FireServer()
  433. --mark as cooking
  434. cookingDict[order]=cookingDict[order]+1
  435. local revoked=false
  436. spawn(function()
  437. raw.AncestryChanged:Wait()
  438. if not revoked then
  439. cookingDict[order]=cookingDict[order]-1
  440. revoked=true
  441. end
  442. end)
  443. delay(40, function()
  444. if not revoked then
  445. cookingDict[order]=cookingDict[order]-1
  446. revoked=true
  447. end
  448. end)
  449. end
  450. end
  451. end
  452. end
  453. --open unnecessarily closed ovens
  454. for _,o in ipairs(ovens) do
  455. local bar = o.Door.Meter.SurfaceGui.ProgressBar.Bar
  456. if o.IsOpen.Value==false and (o.IsCooking.Value==false or (Vector3.new(bar.ImageColor3.r,bar.ImageColor3.g,bar.ImageColor3.b)-Vector3.new(.871,.518,.224)).magnitude>.1) then
  457. if (root.Position-Vector3.new(44.63, 6.60, 45.20)).magnitude>9 then rootMoved = true root.CFrame = CFrame.new(44.63, 6.60, 45.20) wait(.1) end
  458. o.Door.ClickDetector.Detector:FireServer()
  459. break
  460. end
  461. end
  462. --trash
  463. if trash and (trash.IsBurned.Value==false or getOvenNear(trash.Position)==nil or getOvenNear(trash.Position).IsOpen.Value) then
  464. --closed oven breaks if you take burnt out of it
  465. if (root.Position-Vector3.new(44.63, 6.60, 45.20)).magnitude>9 then rootMoved = true root.CFrame = CFrame.new(44.63, 6.60, 45.20) wait(.1) end
  466. workspace.GameService.UpdateObjectProperty:FireServer(true, trash, "CFrame", CFrame.new(47.9,RNG:NextNumber(-10,-30),72.5), remoteKey)
  467. end
  468. if rootMoved then wait(.1) end
  469. end
  470. if doBoxer then
  471. local boxP,boxD = FindBoxingFoods()
  472. local closedBox,openBox,fullBox = FindBoxes()
  473. local rootMoved = false
  474. if boxD and tick()-boxDtick>0.8 then
  475. boxDtick=tick()
  476. if (root.Position-Vector3.new(54.09, 3.80, 23.150)).magnitude>9 then rootMoved = true root.CFrame = CFrame.new(54.09, 3.80, 23.15) wait(.1) end
  477. workspace.GameService.UpdateObjectProperty:FireServer(true, boxD, "CFrame", CFrame.new(63,4.9,-1,-1,0,0,0,1,0,0,0,-1), remoteKey)
  478. end
  479. if fullBox then
  480. if fullBox.Name=="BoxOpen" then
  481. if (root.Position-Vector3.new(54.09, 3.80, 23.150)).magnitude>9 then rootMoved = true root.CFrame = CFrame.new(54.09, 3.80, 23.15) wait(.1) end
  482. workspace.GameService.CloseBox:FireServer(fullBox)
  483. --will be moved next loop
  484. elseif tick()-boxPtick>0.8 then
  485. if (root.Position-Vector3.new(54.09, 3.80, 23.150)).magnitude>9 then rootMoved = true root.CFrame = CFrame.new(54.09, 3.80, 23.15) wait(.1) end
  486. workspace.GameService.UpdateObjectProperty:FireServer(true, fullBox, "CFrame", CFrame.new(68.2,4.4,-1,-1,0,0,0,1,0,0,0,-1), remoteKey)
  487. boxPtick=tick()
  488. end
  489. end
  490. if closedBox and not openBox then
  491. if (root.Position-Vector3.new(54.09, 3.80, 23.150)).magnitude>9 then rootMoved = true root.CFrame = CFrame.new(54.09, 3.80, 23.15) wait(.1) end
  492. workspace.GameService.UpdateObjectProperty:FireServer(true, closedBox, "CFrame", CFrame.new(RNG:NextNumber(62.5,70.5),3.5,RNG:NextNumber(11,25)), remoteKey)
  493. wait()
  494. workspace.GameService.OpenBox:FireServer(closedBox)
  495. end
  496. if openBox and boxP then
  497. if (root.Position-Vector3.new(54.09, 3.80, 23.150)).magnitude>9 then rootMoved = true root.CFrame = CFrame.new(54.09, 3.80, 23.15) wait(.1) end
  498. workspace.GameService.UpdateObjectProperty:FireServer(true, boxP, "Anchored", true, remoteKey)
  499. workspace.GameService.UpdateObjectProperty:FireServer(true, openBox, "Anchored", true, remoteKey)
  500. wait()
  501. workspace.GameService.UpdateObjectProperty:FireServer(true, boxP, "CFrame", openBox.CFrame+Vector3.new(0,-2,0), remoteKey)
  502. wait()
  503. workspace.GameService.AssignPizzaToBox:FireServer(openBox, boxP)
  504. end
  505. if rootMoved then wait(.1) end
  506. end
  507. if doSupplier then
  508. local refill=false
  509. for s,c in pairs(supplyCounts) do
  510. if c <= settings.refill_at then
  511. refill=true
  512. break
  513. end
  514. end
  515. if refill then
  516. local oldcf = root.CFrame
  517. local alt=0
  518. local waiting = false
  519. local waitingTick = 0
  520. local lastBox
  521. while doSupplier do
  522. --check if refill is done otherwise hit buttons
  523. local fulfilled=true
  524. local boxes = workspace.AllSupplyBoxes:GetChildren()
  525. for s,c in pairs(supplyCounts) do
  526. if c<settings.refill_end then
  527. fulfilled=false
  528. local count = 0
  529. if #boxes > 30 then
  530. for i=1,#boxes do
  531. local box = boxes[i]
  532. if bcolorToSupply[box.BrickColor.Name]==s and box.Anchored==false and box.Position.Z < -940 then
  533. count=count+1
  534. end
  535. end
  536. end
  537. if count < 2 then
  538. simTouch(supplyButtons[s])
  539. end
  540. end
  541. end
  542. if fulfilled then
  543. break
  544. end
  545. wait(1.5)
  546. --check if can finish waiting for boxes to move
  547. if waiting and (lastBox.Position.X>42 or tick()-waitingTick>5) then
  548. waiting=false
  549. if lastBox.Position.X<42 then
  550. --clear boxes if stuck
  551. root.CFrame=CFrame.new(20.5,8,-35)
  552. wait(0.1)
  553. local boxes = workspace.AllSupplyBoxes:GetChildren()
  554. for i=1,#boxes do
  555. local box = boxes[i]
  556. if box.Anchored==false and box.Position.Z>-55 then
  557. workspace.GameService.UpdateObjectProperty:FireServer(true, box, "CFrame", CFrame.new(RNG:NextNumber(0,40),RNG:NextNumber(-10,-30),-70), remoteKey)
  558. wait()
  559. end
  560. end
  561. wait(0.1)
  562. end
  563. end
  564. if not waiting then
  565. --move boxes
  566. root.CFrame=CFrame.new(8,12.4,-1020)
  567. wait(0.1)
  568. alt=1-alt
  569. lastBox=nil
  570. local j=0
  571. local boxes = workspace.AllSupplyBoxes:GetChildren()
  572. for i=1,#boxes do
  573. local box = boxes[i]
  574. if box.Anchored==false and box.Position.Z < -940 and bcolorToSupply[box.BrickColor.Name] and supplyCounts[bcolorToSupply[box.BrickColor.Name]]<settings.refill_end then
  575. box.CFrame = CFrame.new(38-4*j,5,-7-5*alt)
  576. workspace.GameService.UpdateObjectProperty:FireServer(true, box, "CFrame", box.CFrame, remoteKey)
  577. lastBox=box
  578. j=j+1
  579. if j>8 then break end
  580. end
  581. end
  582. if alt==0 and lastBox then
  583. waiting=true
  584. waitingTick=tick()
  585. end
  586. end
  587. end
  588. root.CFrame=oldcf
  589. end
  590. end
  591. if doDelivery then
  592. local del = FindFirstDeliveryTool()
  593. if delTool==nil and del then
  594. --get tool
  595. delTool=del
  596. delTool.Handle.CanCollide=false
  597. delTool.Handle.CFrame = root.CFrame
  598. delay(6,forgetDeliveryTool)
  599. elseif delTool and delTool.Parent==character and delTouched==false then
  600. --deliver to house
  601. local housePart = getHousePart(delTool.Name)
  602. if housePart then
  603. delTouched=true
  604. root.CFrame = housePart.CFrame
  605. end
  606. end
  607. end
  608. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement