Advertisement
Not_Infimax

HD Verification

Dec 9th, 2023
787
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 74.29 KB | None | 0 0
  1. local ChatService = game:GetService("Chat")
  2. local PhysicsService = game:GetService("PhysicsService")
  3. local TweenService = game:GetService("TweenService")
  4.  
  5. local Remotes = game.ReplicatedStorage.Remotes
  6. local JobRemotes = Remotes.JobRemotes
  7.  
  8. local HallaPizza = workspace.JobSystem.HallaPizza
  9. local Restaurant = workspace.JobSystem.Restaurant
  10. local IceCream = workspace.JobSystem["Ice Cream"]
  11.  
  12. local JobModule = require(script.Parent.Modules.Job)
  13. local ListOfJobs = require(script.Parent.Modules.ListOfJobs)
  14. local ListOfCustomerMsgs = require(script.Parent.Modules.ListOfCustomerMsgs)
  15. local Orders = require(script.Parent.Modules.Orders)
  16.  
  17. -- Values
  18. local PlayerConnections = {} -- Every Connection that we add along the way
  19. local Animations = {} -- Animations that the player is currently playing
  20. local RoleStocks = {} -- Stocks for a player's sepcific role
  21.  
  22. -- Jobs
  23. local HallaPizzaJob = JobModule.new("HallaPizza", ListOfJobs.HallaPizza.Roles, ListOfJobs.HallaPizza.MaxWorkers)
  24.  
  25. local RestaurantJob = JobModule.new("Restaurant", ListOfJobs.Restaurant.Roles, ListOfJobs.Restaurant.MaxWorkers)
  26.  
  27. local IceCreamJob = JobModule.new("Ice Cream", ListOfJobs["Ice Cream"].Roles, ListOfJobs["Ice Cream"].MaxWorkers)
  28.  
  29. task.wait()
  30.  
  31. PhysicsService:RegisterCollisionGroup("Customers")
  32. PhysicsService:CollisionGroupSetCollidable("Customers", "Players", false)
  33.  
  34. game.Players.PlayerAdded:Connect(function(player)
  35.     -- Set the player values
  36.     PlayerConnections[player] = {}
  37.     Animations[player] = {}
  38.     RoleStocks[player] = 0
  39.     -- Goes through and activates each click detector
  40.     for i, v in pairs(workspace.JobSystem:GetDescendants()) do
  41.         if v:IsA("ClickDetector") then
  42.             JobRemotes.ActivateClickDetector:FireClient(player, v, false)
  43.         end
  44.     end
  45. end)
  46.  
  47. game.Players.PlayerRemoving:Connect(function(player)
  48.     -- Removes Worker from metatables
  49.     HallaPizzaJob.RemoveWorker(player)
  50.     RestaurantJob.RemoveWorker(player)
  51.     IceCreamJob.RemoveWorker(player)
  52.     -- Disconnect all RBX Events
  53.     for i, v in pairs(PlayerConnections[player]) do
  54.         v:Disconnect()
  55.     end
  56.     PlayerConnections[player] = nil
  57.     Animations[player] = nil
  58.     RoleStocks[player] = nil
  59.  
  60.     -- Destroy all Player Customers owned by this player
  61.     for i, v in pairs(workspace.JobSystem.PlayerCustomers:GetChildren()) do
  62.         if v:FindFirstChild("Host") then
  63.             if v:FindFirstChild("Host").Value == player then
  64.                 v:Destroy()
  65.             end
  66.         end
  67.     end
  68. end)
  69.  
  70. local function changeModelTranparency(Model: Model, Transparency: number)
  71.     for _, v: Part in pairs(Model:GetDescendants()) do
  72.         if v:IsA("BasePart") then
  73.             v.Transparency = Transparency
  74.         end
  75.     end
  76. end
  77. local function changeTransparency(model: Model, transparency: number, name)
  78.     for _, v in pairs(model:GetDescendants()) do
  79.         if v.Name == name then
  80.             if v:IsA("BasePart") then
  81.                 v.Transparency = transparency
  82.             elseif v:IsA("Model") then
  83.                 changeModelTranparency(v, transparency)
  84.             end
  85.         end
  86.     end
  87. end
  88.  
  89. --Import the module so you can start using it
  90. local SimplePath = require(script.SimplePath)
  91. function CreatePath(Dummy: Model, Goal)
  92.     --Create a new Path using the Dummy
  93.     local Path = SimplePath.new(Dummy)
  94.  
  95.     --Helps to visualize the path
  96.     Path.Visualize = false
  97.  
  98.     --Dummy knows to compute path again if something blocks the path
  99.     Path.Blocked:Connect(function()
  100.         Path:Run(Goal)
  101.     end)
  102.  
  103.     --If the position of Goal changes at the next waypoint, compute path again
  104.     Path.WaypointReached:Connect(function()
  105.         Path:Run(Goal)
  106.     end)
  107.  
  108.     Path:Run(Goal)
  109. end
  110.  
  111. -- Parameters Player, RoleName
  112. function StartJob(...)
  113.     local pack = table.pack(...)
  114.     local JobName = pack[1]
  115.     local EventName = pack[2]
  116.     local plr = pack[3]
  117.     local role = pack[4]
  118.     local promptTriggeredBy: ProximityPrompt = pack[5]
  119.     if HasJob(plr) then return end
  120.  
  121.     local success = false
  122.     local pay = 0
  123.     if JobName == HallaPizzaJob.JobName then
  124.         success = HallaPizzaJob.AddWorker(plr, role)
  125.         pay = HallaPizzaJob:GetPlayerPay(plr)
  126.     elseif JobName == RestaurantJob.JobName then
  127.         success = RestaurantJob.AddWorker(plr, role)
  128.         pay = RestaurantJob:GetPlayerPay(plr)
  129.     elseif JobName == IceCreamJob.JobName then
  130.         success = IceCreamJob.AddWorker(plr, role)
  131.         pay = IceCreamJob:GetPlayerPay(plr)
  132.     end
  133.  
  134.     if success then
  135.         for i, v:ProximityPrompt in pairs(workspace.JobSystem[JobName].ClaimParts:GetDescendants()) do
  136.             if v:IsA("ProximityPrompt") then
  137.                 JobRemotes.ActivatePrompt:FireClient(plr, v, false)
  138.             elseif v:IsA("ClickDetector") then
  139.                 JobRemotes.ActivateClickDetector:FireClient(plr, v, true)
  140.             end
  141.         end
  142.         JobRemotes.ShowFrames:FireClient(plr, true)
  143.         JobRemotes.ShowStats:FireClient(plr, pay)
  144.     end
  145. end
  146.  
  147. function HasJob(player: Player)
  148.     local JobStats = player:FindFirstChild("JobStats")
  149.  
  150.     if JobStats then
  151.         local HasJob = JobStats:FindFirstChild("HasJob")
  152.  
  153.         if HasJob then
  154.             return HasJob.Value
  155.         end
  156.     end
  157. end
  158.  
  159. --function ChangeRole(...)
  160. --  local pack = table.pack(...)
  161. --  local JobName = pack[1]
  162. --  local EventName = pack[2]
  163. --  local plr = pack[3]
  164. --  local role = pack[4]
  165. --  if not HasJob(plr) then return end
  166.  
  167. --  if JobName == HallaPizzaJob.JobName then
  168. --      HallaPizzaJob.ChangePlayerRole(plr, role)
  169. --  elseif JobName == RestaurantJob.JobName then
  170. --      RestaurantJob.ChangePlayerRole(plr, role)
  171. --  elseif JobName == IceCreamJob.JobName then
  172. --      IceCreamJob.ChangePlayerRole(plr, role)
  173. --  end
  174. --end
  175.  
  176. -- For every building, the interaction with the cashier and customer
  177. function CashierCustomerAction(...)
  178.     local pack = table.pack(...)
  179.     local JobName = pack[1]
  180.     local ActionName = pack[2]
  181.     local plr = pack[3]
  182.     local role = pack[4]
  183.     if not HasJob(plr) then return end
  184.  
  185.     local Customers = game.ReplicatedStorage.Customers:GetChildren()
  186.     local Customer = Customers[math.random(1, #Customers)]:Clone()
  187.     Customer.Parent = workspace.JobSystem.PlayerCustomers
  188.     Customer.HumanoidRootPart:SetNetworkOwner(plr)
  189.    
  190.     local Host = Instance.new("ObjectValue", Customer)
  191.     Host.Name = "Host"
  192.     Host.Value = plr
  193.  
  194.     for i, v: BasePart in pairs(Customer:GetDescendants()) do
  195.         if v:IsA("BasePart") then
  196.             v.CollisionGroup = "Customers"
  197.         end
  198.     end
  199.  
  200.     local Humanoid: Humanoid = Customer:WaitForChild("Humanoid")
  201.     local Register
  202.     local Waypoints
  203.     if JobName == HallaPizzaJob.JobName then
  204.         local Registers = HallaPizza.Registers
  205.         if Registers.Register1.Owner.Value == plr then
  206.             Register = Registers.Register1
  207.         elseif Registers.Register2.Owner.Value == plr then
  208.             Register = Registers.Register2
  209.         end
  210.  
  211.         if Register then
  212.             Waypoints = HallaPizza.Waypoints:FindFirstChild(Register.Name)
  213.         else
  214.             return
  215.         end
  216.  
  217.     elseif JobName == RestaurantJob.JobName then
  218.         local Registers = Restaurant.Registers
  219.         if Registers.Register1.Owner.Value == plr then
  220.             Register = Registers.Register1
  221.         elseif Registers.Register2.Owner.Value == plr then
  222.             Register = Registers.Register2
  223.         end
  224.  
  225.         if Register then
  226.             Waypoints = Restaurant.Waypoints:FindFirstChild(Register.Name)
  227.         else
  228.             return
  229.         end
  230.     elseif JobName == IceCreamJob.JobName then
  231.         local Registers = IceCream.Registers
  232.         if Registers.Register1.Owner.Value == plr then
  233.             Register = Registers.Register1
  234.         elseif Registers.Register2.Owner.Value == plr then
  235.             Register = Registers.Register2
  236.         end
  237.  
  238.         if Register then
  239.             Waypoints = IceCream.Waypoints:FindFirstChild(Register.Name)
  240.         else
  241.             return
  242.         end
  243.     end
  244.  
  245.     Customer.HumanoidRootPart.CFrame = Waypoints:FindFirstChild("1").CFrame * CFrame.new(0, 2, 0)
  246.  
  247.     --CreatePath(Customer, Waypoints:FindFirstChild("5"))
  248.     if Waypoints:FindFirstChild('3') then
  249.         Humanoid:MoveTo(Waypoints['3'].Position)
  250.         Humanoid.MoveToFinished:Wait()
  251.     end
  252.  
  253.     Humanoid:MoveTo(Waypoints['5'].Position)
  254.  
  255.     task.wait(1)
  256.  
  257.     local prefix = ListOfCustomerMsgs.Prefix[math.random(1, #ListOfCustomerMsgs.Prefix)]
  258.     local suffix = ListOfCustomerMsgs.Suffix[JobName][math.random(1, #ListOfCustomerMsgs.Suffix[JobName])]
  259.     local msg = prefix .. suffix.Message
  260.  
  261.     ChatService:Chat(Customer:WaitForChild("Head"), msg, Enum.ChatColor.White)
  262.  
  263.     local CashierGui
  264.  
  265.     -- Sets the CashierGui to One or Two
  266.     if JobName == HallaPizzaJob.JobName or JobName == RestaurantJob.JobName  then
  267.         CashierGui = plr.PlayerGui.CashierGui
  268.     elseif JobName == IceCreamJob.JobName then
  269.         CashierGui = plr.PlayerGui.CashierGui2
  270.     end
  271.  
  272.     CashierGui.Adornee = Register.CashRegister.Value["Screen"]
  273.  
  274.     for i = 1, #CashierGui:GetChildren() do
  275.         local clickConnection
  276.  
  277.         local function btnClick()
  278.             print('Clicked')
  279.             if i == suffix.Order then
  280.                 if JobName == HallaPizzaJob.JobName then
  281.                     HallaPizzaJob:Pay(plr)
  282.                     ChatService:Chat(Customer.Head, "Thanks for the Pizza 🍕!!", Enum.ChatColor.White)
  283.                 elseif JobName == RestaurantJob.JobName then
  284.                     RestaurantJob:Pay(plr)
  285.                     ChatService:Chat(Customer.Head, "Thanks for the food 🍽️!!", Enum.ChatColor.White)
  286.                 elseif JobName == IceCreamJob.JobName then
  287.                     IceCreamJob:Pay(plr)
  288.                     ChatService:Chat(Customer.Head, "Thanks for the Ice Cream 🍦!!", Enum.ChatColor.White)
  289.                 end
  290.             else
  291.                 ChatService:Chat(Customer.Head, "Ugh, you got my order wrong!!", Enum.ChatColor.White)
  292.             end
  293.             for i, v in pairs(PlayerConnections[plr]) do
  294.                 v:Disconnect()
  295.             end
  296.  
  297.             task.wait(1)
  298.  
  299.             -- Creates the path to leave the building
  300.             if Waypoints:FindFirstChild("3") then
  301.                 --CreatePath(Customer, Waypoints:FindFirstChild("3").Position)
  302.                 Humanoid:MoveTo(Waypoints['3'].Position)
  303.                 Humanoid.MoveToFinished:Wait()
  304.             end
  305.  
  306.             CreatePath(Customer, Waypoints:FindFirstChild("1").Position)
  307.  
  308.             task.wait(5)
  309.  
  310.             Customer:Destroy()
  311.  
  312.             CashierCustomerAction(table.unpack(pack))
  313.         end
  314.  
  315.         clickConnection = CashierGui:FindFirstChild(i).Btn.MouseButton1Click:Connect(btnClick)
  316.        
  317.         table.insert(PlayerConnections[plr], clickConnection)
  318.     end
  319. end
  320.  
  321. -- The Delivery, Pizza Runners.
  322. function CustomerAction2(...)
  323.     local pack = table.pack(...)
  324.     local JobName = pack[1]
  325.     local ActionName = pack[2]
  326.     local plr = pack[3]
  327.     local role = pack[4]
  328.     if not HasJob(plr) then return end
  329.  
  330.     local Register
  331.     local Waypoints
  332.     if JobName == HallaPizzaJob.JobName then
  333.         Waypoints = HallaPizza.Waypoints.Seats
  334.     elseif JobName == RestaurantJob.JobName then
  335.         Waypoints = Restaurant.Waypoints.Seats
  336.     elseif JobName == IceCreamJob.JobName then
  337.         Waypoints = IceCream.Waypoints.Seats
  338.     end
  339.  
  340.     local Max = #Waypoints:GetChildren() - 2
  341.     local num = math.random(3, Max)
  342.     local seat: Seat = Waypoints:FindFirstChild(num)
  343.  
  344.     if seat.Occupant == nil then
  345.         local maxAttempts = 24
  346.         local attempts = 0
  347.         repeat
  348.             num = math.random(3, Max)
  349.             seat = Waypoints:FindFirstChild(num)
  350.             attempts += 1
  351.         until seat.Occupant == nil and attempts ~= maxAttempts
  352.     end
  353.  
  354.     local Customer: Model = game.ReplicatedStorage.Customers:GetChildren()
  355.     Customer = Customer[math.random(1, #Customer)]:Clone()
  356.     Customer.Parent = workspace.JobSystem.PlayerCustomers
  357.  
  358.     for i, v: BasePart in pairs(Customer:GetDescendants()) do
  359.         if v:IsA("BasePart") then
  360.             v.CollisionGroup = "Customers"
  361.         end
  362.     end
  363.  
  364.     local Host = Instance.new("ObjectValue", Customer)
  365.     Host.Name = "Host"
  366.     Host.Value = plr
  367.  
  368.     local Humanoid: Humanoid = Customer:WaitForChild("Humanoid")
  369.  
  370.     Customer.HumanoidRootPart.CFrame = Waypoints:FindFirstChild(math.random(1,2)).CFrame * CFrame.new(0, 2, 0)
  371.     CreatePath(Customer, (seat.CFrame * CFrame.new(-4, 0, 0)).Position)
  372.  
  373.     task.wait(4)
  374.  
  375.     seat:Sit(Humanoid)
  376.  
  377.     local suffix = ListOfCustomerMsgs.Suffix[JobName][math.random(1, #ListOfCustomerMsgs.Suffix[JobName])]
  378.  
  379.     local CustomerTag = script.CustomerTag:Clone()
  380.     local Head = Customer:WaitForChild("Head")
  381.     if Head then
  382.         CustomerTag.Parent = Head
  383.     end
  384.  
  385.     CustomerTag.Frame.Icon.Image = suffix.Icon
  386.  
  387.     local ClickDetector = Instance.new("ClickDetector", Customer)
  388.  
  389.     local location
  390.     if JobName == HallaPizzaJob.JobName then
  391.         location = HallaPizza.ClickDetectors.Pizza
  392.     elseif JobName == RestaurantJob.JobName then
  393.         location = Restaurant.ClickDetectors.Meals
  394.     end
  395.  
  396.     for i, v in pairs(location:GetDescendants()) do
  397.         if v:IsA("ClickDetector") then
  398.             JobRemotes.ActivateClickDetector:FireClient(plr, v, true)
  399.         end
  400.     end
  401.  
  402.     local connection
  403.     connection = ClickDetector.MouseClick:Connect(function(player)
  404.         if JobName == HallaPizzaJob.JobName then
  405.             if HallaPizzaJob:IsRoleWorker("Pizza Runner", player) then
  406.                 local tool = player.Character:FindFirstChildWhichIsA("Folder")
  407.                 if tool then
  408.                     CustomerTag:Destroy()
  409.                     tool:Destroy()
  410.                     if Animations[player]["Holding Pizza"] then
  411.                         Animations[player]["Holding Pizza"]:Stop()
  412.                         Animations[player]["Holding Pizza"] = nil
  413.                     end
  414.                     if tool.Name == suffix.Name then
  415.                         HallaPizzaJob:Pay(plr)
  416.                         ChatService:Chat(Customer.Head, "Thanks for the Pizza 🍕!!", Enum.ChatColor.White)
  417.  
  418.                         coroutine.wrap(function()
  419.                             CustomerAction2(table.unpack(pack))
  420.                         end)() 
  421.                         task.wait(1) -- Time between Meal and Leaving
  422.  
  423.                         if seat:FindFirstChildWhichIsA("Weld") then
  424.                             seat:FindFirstChildWhichIsA("Weld"):Destroy()
  425.                         end
  426.  
  427.                         Customer:Destroy()
  428.                     else
  429.                         ChatService:Chat(Customer.Head, "Ugh, you got my order wrong!!", Enum.ChatColor.White)
  430.  
  431.                         coroutine.wrap(function()
  432.                             CustomerAction2(table.unpack(pack))
  433.                         end)()
  434.  
  435.                         task.wait(2) -- Time between Order and Leaving
  436.  
  437.                         if seat:FindFirstChildWhichIsA("Weld") then
  438.                             seat:FindFirstChildWhichIsA("Weld"):Destroy()
  439.                         end
  440.  
  441.                         Customer:Destroy()
  442.                     end
  443.                 end
  444.                 connection:Disconnect()
  445.             end
  446.         elseif JobName == RestaurantJob.JobName then
  447.             local tool = player.Character:FindFirstChildWhichIsA("Folder")
  448.             if tool then
  449.                 CustomerTag:Destroy()
  450.                 tool:Destroy()
  451.             end
  452.             if RestaurantJob:IsRoleWorker("Delivery", player) then
  453.                 local tool = player.Character:FindFirstChildWhichIsA("Folder")
  454.                 if tool then
  455.                     CustomerTag:Destroy()
  456.                     tool:Destroy()
  457.                     if Animations[player]["Holding Plate"] then
  458.                         Animations[player]["Holding Plate"]:Stop()
  459.                         Animations[player]["Holding Plate"] = nil
  460.                     end
  461.                     if tool.Name == suffix.Name then
  462.                         RestaurantJob:Pay(plr)
  463.                         ChatService:Chat(Customer.Head, "Thanks for the Meal 🍽️!!", Enum.ChatColor.White)
  464.  
  465.                         coroutine.wrap(function()
  466.                             CustomerAction2(table.unpack(pack))
  467.                         end)()
  468.  
  469.                         task.wait(2) -- Time between Meal and Leaving
  470.  
  471.                         if seat:FindFirstChildWhichIsA("Weld") then
  472.                             seat:FindFirstChildWhichIsA("Weld"):Destroy()
  473.                         end
  474.  
  475.                         Customer:Destroy()
  476.                     else
  477.                         ChatService:Chat(Customer.Head, "Ugh, you got my order wrong!!", Enum.ChatColor.White)
  478.  
  479.                         coroutine.wrap(function()
  480.                             CustomerAction2(table.unpack(pack))
  481.                         end)()
  482.  
  483.                         task.wait(2) -- Time between Order and Leaving
  484.  
  485.                         if seat:FindFirstChildWhichIsA("Weld") then
  486.                             seat:FindFirstChildWhichIsA("Weld"):Destroy()
  487.                         end
  488.  
  489.                         Customer:Destroy()
  490.                     end
  491.                 end
  492.  
  493.                 connection:Disconnect()
  494.             end
  495.         end
  496.     end)
  497. end
  498.  
  499. local maxRolls = 6
  500. function DoughMakerAction(...)
  501.     local pack = table.pack(...)
  502.     local JobName = pack[1]
  503.     local EventName = pack[2]
  504.     local plr = pack[3]
  505.     local station = pack[4]
  506.     if not HasJob(plr) then return end
  507.  
  508.     -- Process, Step 1: Click the Board, Step 2: Click the Dough, Step 3: Click the Roller
  509.     local clicks = {
  510.         first = false,
  511.         second = false,
  512.         third = false,
  513.     }
  514.  
  515.     local dly = 0.5
  516.  
  517.     local Table: Part = HallaPizza.ObjectValues.DoughMaker["Table" .. station].Value
  518.     local Board: Part = HallaPizza.ObjectValues.DoughMaker["Board" .. station].Value
  519.     local Dough: Part = HallaPizza.ObjectValues.DoughMaker["Dough" .. station].Value
  520.     local Roller: Model = HallaPizza.ObjectValues.DoughMaker["Roller" .. station].Value
  521.  
  522.     local BoardItem = HallaPizza.DoughMakerItems["Board" .. station]
  523.     local DoughItem = HallaPizza.DoughMakerItems["Dough" .. station]
  524.     local RollerItem = HallaPizza.DoughMakerItems["Roller" .. station]
  525.  
  526.     local needToRestock = false -- whether it needs to restock or not
  527.  
  528.     -- Show the Arrow on top of the board
  529.     JobRemotes.ShowArrow:FireClient(plr, Board)
  530.  
  531.     local Table = HallaPizza.ClickDetectors.DoughMaker["Table" .. station]
  532.     local StandCFrame = Table.CFrame * CFrame.new(0,0,3)
  533.  
  534.     JobRemotes.ActivateClickDetector:FireClient(plr, Table.ClickDetector, false)
  535.  
  536.     local Box = HallaPizza.ClickDetectors.DoughMaker["Box"]
  537.     local restockConnection
  538.     if RoleStocks[plr] == maxRolls then
  539.         needToRestock = true
  540.         plr.Character.Humanoid.WalkSpeed = game.StarterPlayer.CharacterWalkSpeed
  541.         plr.Character.Humanoid.JumpPower = game.StarterPlayer.CharacterJumpPower
  542.  
  543.         JobRemotes.ActivateClickDetector:FireClient(plr, Box.ClickDetector, true)
  544.         -- Box Interaction
  545.         restockConnection = Box.ClickDetector.MouseClick:Connect(function(player)
  546.             if player ~= plr then return end
  547.  
  548.             JobRemotes.ShowArrow:FireClient(plr, Table)
  549.  
  550.             Table.ClickDetector.MaxActivationDistance = 32
  551.  
  552.             local anim = game.ReplicatedStorage.Animations.HoldBox
  553.             Animations[plr]["Holding Box"] = player.Character.Humanoid.Animator:LoadAnimation(anim)
  554.             Animations[plr]["Holding Box"]:Play()
  555.  
  556.             local boxDist = 1
  557.  
  558.             local Box = game.ReplicatedStorage.Tools.HallaPizza.Box:Clone()
  559.             Box.Parent = player.Character
  560.             Box.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, boxDist)
  561.  
  562.             local Weld = Instance.new("Weld", Box)
  563.             Weld.Part0 = Box
  564.             Weld.Part1 = player.Character.HumanoidRootPart
  565.             Weld.C0 = Box.CFrame:Inverse() * player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, boxDist)
  566.  
  567.             local TableConnection
  568.             TableConnection = Table.ClickDetector.MouseClick:Connect(function(player)
  569.                 if player ~= plr then return end
  570.                 -- Reset ClickDetector back to default
  571.                 Table.ClickDetector.MaxActivationDistance = 0
  572.  
  573.                 Box:Destroy()
  574.                 Weld:Destroy()
  575.                 player.Character.Humanoid.WalkSpeed = 0
  576.                 player.Character.Humanoid.JumpPower = 0
  577.  
  578.                 player.Character.HumanoidRootPart.CFrame = StandCFrame
  579.  
  580.                 Animations[plr]["Holding Box"]:Stop()
  581.  
  582.                 -- Reset rolls and set needToRestock to false
  583.                 RoleStocks[player] = 0
  584.                 needToRestock = false
  585.  
  586.                 JobRemotes.ShowArrow:FireClient(plr, Board)
  587.             end)
  588.             table.insert(PlayerConnections[player], TableConnection)
  589.         end)
  590.         -- Show the Arrow on top of the board
  591.         JobRemotes.ShowArrow:FireClient(plr, Box)
  592.     else
  593.         plr.Character.Humanoid.WalkSpeed = 0
  594.         plr.Character.Humanoid.JumpPower = 0
  595.         plr.Character.HumanoidRootPart.CFrame = StandCFrame
  596.  
  597.     end
  598.  
  599.     JobRemotes.ActivateClickDetector:FireClient(plr, HallaPizza.ClickDetectors.DoughMaker["Board"..station].ClickDetector, true)
  600.     JobRemotes.ActivateClickDetector:FireClient(plr, HallaPizza.ClickDetectors.DoughMaker["Dough"..station].ClickDetector, true)
  601.     JobRemotes.ActivateClickDetector:FireClient(plr, HallaPizza.ClickDetectors.DoughMaker["Roller"..station].ClickDetector, true)
  602.  
  603.     local connection
  604.     connection = HallaPizza.ClickDetectors.DoughMaker["Board" .. station].ClickDetector.MouseClick:Connect(function(player: Player)
  605.         if player ~= plr then return end
  606.         if needToRestock then return end
  607.  
  608.         task.wait(dly)
  609.  
  610.         BoardItem.Transparency = 0
  611.  
  612.         JobRemotes.ShowArrow:FireClient(plr, Dough)
  613.  
  614.         clicks.first = true
  615.         connection:Disconnect()
  616.     end)
  617.  
  618.     local connection2
  619.     connection2 = HallaPizza.ClickDetectors.DoughMaker["Dough" .. station].ClickDetector.MouseClick:Connect(function(player)
  620.         if player ~= plr then return end
  621.         if not clicks.first then return end
  622.         if needToRestock then return end
  623.  
  624.         task.wait(dly)
  625.  
  626.         DoughItem.Transparency = 0
  627.  
  628.         JobRemotes.ShowArrow:FireClient(plr, Roller)
  629.  
  630.         clicks.second = true
  631.         connection2:Disconnect()
  632.     end)
  633.  
  634.     local connection3
  635.     connection3 = HallaPizza.ClickDetectors.DoughMaker["Roller" .. station].ClickDetector.MouseClick:Connect(function(player)
  636.         if player ~= plr then return end
  637.         if not clicks.first or not clicks.second then return end
  638.         if needToRestock then return end
  639.  
  640.         task.wait(dly)
  641.  
  642.         for i, v in pairs(RollerItem:GetChildren()) do
  643.             if v:IsA("BasePart") then
  644.                 v.Transparency = 0
  645.             end
  646.         end
  647.  
  648.         clicks.third = true
  649.         HallaPizzaJob:Pay(plr)
  650.         connection3:Disconnect()
  651.         RoleStocks[plr] += 1
  652.  
  653.         local duration = 0.5
  654.         local travelDist = 3
  655.  
  656.         local initialCFrame = RollerItem.PrimaryPart.CFrame
  657.  
  658.         local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 3, true)
  659.         local tween = TweenService:Create(RollerItem.PrimaryPart, tweenInfo, {
  660.             CFrame = (RollerItem.PrimaryPart.CFrame * CFrame.new(0, 0, -travelDist))
  661.         })
  662.  
  663.         local anim = game.ReplicatedStorage.Animations.HallaPizza.RollingAnimation
  664.         Animations[player]["Rolling Animation"] = player.Character.Humanoid.Animator:LoadAnimation(anim)
  665.         Animations[player]["Rolling Animation"]:Play()
  666.  
  667.         tween:Play()
  668.  
  669.  
  670.         tween.Completed:Wait()
  671.         Animations[player]["Rolling Animation"]:Stop()
  672.         Animations[player]["Rolling Animation"] = nil
  673.  
  674.         -- Reset back to initial transparency
  675.         for i, v in pairs(RollerItem:GetChildren()) do
  676.             if v:IsA("BasePart") then
  677.                 v.Transparency = 1
  678.             end
  679.         end
  680.         BoardItem.Transparency = 1
  681.         DoughItem.Transparency = 1
  682.  
  683.         RollerItem.PrimaryPart.CFrame = initialCFrame
  684.  
  685.         plr.Character.Humanoid.WalkSpeed = game.StarterPlayer.CharacterWalkSpeed
  686.         plr.Character.Humanoid.JumpPower = game.StarterPlayer.CharacterJumpPower
  687.  
  688.         DoughMakerAction(table.unpack(pack))
  689.     end)
  690.  
  691.     table.insert(PlayerConnections[plr], connection) -- insert connection so we can disconnect later
  692.     table.insert(PlayerConnections[plr], connection2) -- insert connection so we can disconnect later
  693.     table.insert(PlayerConnections[plr], connection3) -- insert connection so we can disconnect later
  694.     table.insert(PlayerConnections[plr], restockConnection) -- insert connection so we can disconnect later
  695. end
  696.  
  697. local maxPizza = 8
  698. function PizzaMakerAction(...)
  699.     local pack = table.pack(...)
  700.     local JobName = pack[1]
  701.     local EventName = pack[2]
  702.     local plr = pack[3]
  703.     local station = pack[4]
  704.     if not HasJob(plr) then return end
  705.  
  706.     local pizza = Orders.Clone(Orders.HallaPizza.Order[math.random(1, #Orders.HallaPizza.Order)])
  707.     local PizzaModel = HallaPizza.PizzaMakerItems["Pizza" .. station]
  708.  
  709.     local PM = HallaPizza.ObjectValues.PizzaMaker
  710.     local PMC = HallaPizza.ClickDetectors.PizzaMaker
  711.     local Screen =  PM["Screen" .. station].Value
  712.  
  713.     local inStock = true
  714.     local Table = HallaPizza.ClickDetectors.PizzaMaker["Table"..station]
  715.  
  716.     JobRemotes.ActivateClickDetector:FireClient(plr, Table.ClickDetector, false)
  717.     JobRemotes.ActivateClickDetector:FireClient(plr, HallaPizza.ClickDetectors.PizzaMaker["Box"].ClickDetector, false)
  718.  
  719.     if RoleStocks[plr] == maxPizza then
  720.         Screen.GUI.Icon.Image = "http://www.roblox.com/asset/?id=12232016774" -- Restock Icon
  721.         inStock = false
  722.         JobRemotes.ShowArrow:FireClient(plr, HallaPizza.ClickDetectors.PizzaMaker["Box"])
  723.  
  724.         JobRemotes.ActivateClickDetector:FireClient(plr, HallaPizza.ClickDetectors.PizzaMaker["Box"].ClickDetector, true)
  725.  
  726.         local connection
  727.         connection = HallaPizza.ClickDetectors.PizzaMaker["Box"].ClickDetector.MouseClick:Connect(function(player)
  728.             if player ~= plr then return end
  729.  
  730.             local anim = game.ReplicatedStorage.Animations.HoldBox
  731.             Animations[plr]["Holding Box"] = player.Character.Humanoid.Animator:LoadAnimation(anim)
  732.             Animations[plr]["Holding Box"]:Play()
  733.  
  734.             local boxDist = 1
  735.  
  736.             local Box = game.ReplicatedStorage.Tools.HallaPizza.Box:Clone()
  737.             Box.Parent = player.Character
  738.             Box.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, boxDist)
  739.  
  740.             local Weld = Instance.new("Weld", Box)
  741.             Weld.Part0 = Box
  742.             Weld.Part1 = player.Character.HumanoidRootPart
  743.             Weld.C0 = Box.CFrame:Inverse() * player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, boxDist)
  744.  
  745.             JobRemotes.ActivateClickDetector:FireClient(plr, Table.ClickDetector, true)        
  746.             JobRemotes.ShowArrow:FireClient(plr, Table)
  747.             connection:Disconnect()
  748.         end)
  749.  
  750.         local connection2
  751.         connection2 = Table.ClickDetector.MouseClick:Connect(function(player)
  752.             if player ~= plr then return end
  753.  
  754.             task.wait(0.5)
  755.             inStock = true
  756.  
  757.             JobRemotes.ActivateClickDetector:FireClient(plr, HallaPizza.ClickDetectors.PizzaMaker["Table"..station].ClickDetector, false)
  758.             if plr.Character:FindFirstChild("Box") then
  759.                 plr.Character:FindFirstChild("Box"):Destroy()
  760.                 Animations[plr]["Holding Box"]:Stop()
  761.                 Animations[plr]["Holding Box"] = nil
  762.             end
  763.  
  764.             player.Character.Humanoid.WalkSpeed = 0
  765.             player.Character.Humanoid.JumpPower = 0
  766.             player.Character.HumanoidRootPart.CFrame = Table.CFrame * CFrame.new(0,0,3)
  767.  
  768.             RoleStocks[plr] = 0
  769.             connection2:Disconnect()
  770.         end)
  771.         table.insert(PlayerConnections[plr], connection)
  772.         table.insert(PlayerConnections[plr], connection2)
  773.         repeat task.wait()
  774.             if connection2 == nil then
  775.                 break
  776.             end
  777.         until inStock
  778.     else
  779.         plr.Character.Humanoid.WalkSpeed = 0
  780.         plr.Character.Humanoid.JumpPower = 0
  781.         plr.Character.HumanoidRootPart.CFrame = Table.CFrame * CFrame.new(0,0,3)
  782.     end
  783.  
  784.     Screen.GUI.Icon.Image = pizza.Icon
  785.  
  786.     local clicks = pizza.Clicks
  787.     local isRunning = true
  788.     local isOnNumber = 1
  789.  
  790.     for i = 1, #Orders.HallaPizza.ClickDetectors do
  791.         local CDNAME = Orders.HallaPizza.ClickDetectors[i]
  792.         local isInRecipe = false
  793.         for _, k in pairs(clicks) do
  794.             if k.Name == CDNAME then
  795.                 isInRecipe = true
  796.             end
  797.         end
  798.  
  799.         if not isInRecipe then
  800.             local connection
  801.             JobRemotes.ActivateClickDetector:FireClient(plr, PMC[CDNAME .. station].ClickDetector, true)
  802.             connection = PMC[CDNAME .. station].ClickDetector.MouseClick:Connect(function(player)
  803.                 if player ~= plr then return end
  804.  
  805.                 isRunning = false
  806.                 changeModelTranparency(PizzaModel, 1)
  807.                 for i, v in pairs(PlayerConnections[plr]) do
  808.                     v:Disconnect()
  809.                 end
  810.  
  811.                 plr.Character.Humanoid.WalkSpeed = game.StarterPlayer.CharacterWalkSpeed
  812.                 plr.Character.Humanoid.JumpPower = game.StarterPlayer.CharacterJumpPower
  813.                 RoleStocks[plr] += 1
  814.                 PizzaMakerAction(table.unpack(pack))
  815.             end)
  816.             table.insert(PlayerConnections[plr], connection)
  817.         end
  818.     end
  819.  
  820.     for i = 1, #clicks do
  821.         local click = clicks[i]
  822.         local name = click.Name .. station
  823.  
  824.         if i == 1 then
  825.             JobRemotes.ShowArrow:FireClient(plr, PMC[name])
  826.         end
  827.  
  828.         local connection
  829.         JobRemotes.ActivateClickDetector:FireClient(plr, PMC[name].ClickDetector, true)
  830.         connection = PMC[name].ClickDetector.MouseClick:Connect(function(player)
  831.             if player ~= plr then return end
  832.  
  833.             if i ~= 1 then
  834.                 local clminus = clicks[i - 1] -- Current one minus 1 (to go back)
  835.                 if clminus then
  836.                     if not clminus.Done then
  837.                         isRunning = false
  838.                         changeModelTranparency(PizzaModel, 1)
  839.                         RoleStocks[plr] += 1
  840.                         PizzaMakerAction(table.unpack(pack))
  841.                         connection:Disconnect()
  842.                         return
  843.                     end
  844.                 end
  845.             end
  846.  
  847.             task.wait(0.5)
  848.             changeTransparency(PizzaModel, 0, click.Name)
  849.  
  850.             task.wait(0.5)
  851.  
  852.             if i == #clicks then
  853.                 for i, v in pairs(PlayerConnections[plr]) do
  854.                     v:Disconnect()
  855.                     PlayerConnections[plr][i] = nil
  856.                 end
  857.  
  858.                 local clone: Model = PizzaModel:Clone()
  859.                 clone.Parent = workspace.JobSystem.Items
  860.  
  861.                 local Host = Instance.new("ObjectValue", clone)
  862.                 Host.Value = plr
  863.  
  864.                 if clone.PrimaryPart then
  865.                     coroutine.wrap(function()
  866.                         local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
  867.                         for i = 1, 3 do
  868.                             local waypoint: Part = HallaPizza.Waypoints.PizzaMaker[i]
  869.                             if waypoint then
  870.                                 local tween = TweenService:Create(clone.PrimaryPart, tweenInfo, {
  871.                                     CFrame = waypoint.CFrame * CFrame.Angles(math.rad(-90), 0, 0)
  872.                                 })
  873.                                 tween:Play()
  874.                                 tween.Completed:Wait()
  875.                             end
  876.                         end
  877.                         clone:Destroy()
  878.                     end)()
  879.                 end
  880.  
  881.                 plr.Character.Humanoid.WalkSpeed = game.StarterPlayer.CharacterWalkSpeed
  882.                 plr.Character.Humanoid.JumpPower = game.StarterPlayer.CharacterJumpPower
  883.  
  884.                 isRunning = false
  885.                 changeModelTranparency(PizzaModel, 1)              
  886.                 HallaPizzaJob:Pay(plr)
  887.                 RoleStocks[plr] += 1
  888.                 PizzaMakerAction(table.unpack(pack))
  889.             end
  890.  
  891.  
  892.             isOnNumber += 1
  893.             click.Done = true
  894.             connection:Disconnect()
  895.         end)
  896.         table.insert(PlayerConnections[plr], connection)
  897.     end
  898.  
  899.     coroutine.wrap(function()
  900.         while isRunning do
  901.             if #PlayerConnections[plr] == 0 then
  902.                 break
  903.             end
  904.  
  905.             if isOnNumber ~= 1 then
  906.                 JobRemotes.ShowArrow:FireClient(plr, PMC[clicks[isOnNumber].Name .. station])
  907.             end
  908.             task.wait()
  909.         end
  910.     end)()
  911. end
  912.  
  913. function DishWasherAction(...)
  914.     local pack = table.pack(...)
  915.     local JobName = pack[1]
  916.     local EventName = pack[2]
  917.     local plr = pack[3]
  918.     local station = pack[4]
  919.     if not HasJob(plr) then return end
  920.  
  921.     local clicks = {
  922.         first = false,
  923.         second = false
  924.     }
  925.  
  926.     local Dishes = Restaurant.ClickDetectors.DishWasher["Dishes" .. station]
  927.     local Sink = Restaurant.ClickDetectors.DishWasher["Sink" .. station]
  928.     local Plate = Restaurant.DishWasherItems["Plate"..station]
  929.     local Water = Restaurant.DishWasherItems["Water"..station]
  930.     local Table = Restaurant.DishWasherItems["Table"..station]
  931.  
  932.     JobRemotes.ShowArrow:FireClient(plr, Dishes)
  933.  
  934.     JobRemotes.ActivateClickDetector:FireClient(plr, Dishes.ClickDetector, true)
  935.     JobRemotes.ActivateClickDetector:FireClient(plr, Sink.ClickDetector, true)
  936.  
  937.     plr.Character.Humanoid.WalkSpeed = 0
  938.     plr.Character.Humanoid.JumpPower = 0
  939.  
  940.     plr.Character.HumanoidRootPart.CFrame = Table.CFrame * CFrame.new(-3,0, 0) * CFrame.Angles(0, -math.rad(90), 0)
  941.  
  942.     local connection
  943.     connection = Dishes.ClickDetector.MouseClick:Connect(function(player)
  944.         if player ~= plr then return end
  945.  
  946.         Plate.Transparency = 0
  947.         JobRemotes.ShowArrow:FireClient(plr, Sink)
  948.  
  949.         clicks.first = true
  950.         connection:Disconnect()
  951.     end)
  952.  
  953.     local connection2
  954.     connection2 = Sink.ClickDetector.MouseClick:Connect(function(player: Player)
  955.         if player ~= plr then return end
  956.         if not clicks.first then return end
  957.  
  958.         Water.ParticleEmitter.Enabled = true
  959.  
  960.         local anim = game.ReplicatedStorage.Animations.Restaurant.Cleaning
  961.         Animations[plr]["Cleaning"] = player.Character.Humanoid.Animator:LoadAnimation(anim)
  962.         Animations[plr]["Cleaning"]:Play()
  963.  
  964.         task.wait(3)
  965.         Plate.Transparency = 1
  966.         Water.ParticleEmitter.Enabled = false
  967.         Animations[plr]["Cleaning"]:Stop()
  968.         Animations[plr]["Cleaning"] = nil
  969.         connection2:Disconnect()
  970.         RestaurantJob:Pay(plr)
  971.         DishWasherAction(table.unpack(pack))
  972.         clicks.second = true
  973.     end)
  974.     table.insert(PlayerConnections[plr], connection)
  975.     table.insert(PlayerConnections[plr], connection2)
  976.  
  977. end
  978.  
  979. local MaxStocks = 7
  980. function CookerAction(...)
  981.     local pack = table.pack(...)
  982.     local JobName = pack[1]
  983.     local EventName = pack[2]
  984.     local plr = pack[3]
  985.     local station = pack[4]
  986.     if not HasJob(plr) then return end
  987.  
  988.     local inStock = true
  989.  
  990.     if RoleStocks[plr] == MaxStocks then
  991.         inStock = false
  992.  
  993.         JobRemotes.ShowArrow:FireClient(plr, Restaurant.ClickDetectors.Cooker.Box)
  994.         JobRemotes.ActivateClickDetector:FireClient(plr, Restaurant.ClickDetectors.Cooker.Box.ClickDetector, true)
  995.         local connection
  996.         connection = Restaurant.ClickDetectors.Cooker.Box.ClickDetector.MouseClick:Connect(function(player)
  997.             if player ~= player then return end
  998.  
  999.             local boxDist = 1
  1000.  
  1001.             local Box = game.ReplicatedStorage.Tools.Restaurant.Box:Clone()
  1002.             Box.Parent = player.Character
  1003.             Box.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, boxDist)
  1004.  
  1005.             local Weld = Instance.new("Weld", Box)
  1006.             Weld.Part0 = Box
  1007.             Weld.Part1 = player.Character.HumanoidRootPart
  1008.             Weld.C0 = Box.CFrame:Inverse() * player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, boxDist)
  1009.  
  1010.             local anim = game.ReplicatedStorage.Animations.HoldBox
  1011.             Animations[plr]["Holding Box"] = player.Character.Humanoid.Animator:LoadAnimation(anim)
  1012.             Animations[plr]["Holding Box"]:Play()
  1013.  
  1014.             JobRemotes.ShowArrow:FireClient(plr, Restaurant.ClickDetectors.Cooker.Restock)
  1015.             JobRemotes.ActivateClickDetector:FireClient(plr, Restaurant.ClickDetectors.Cooker.Restock.ClickDetector, true)
  1016.  
  1017.             local connection2
  1018.             connection2 = Restaurant.ClickDetectors.Cooker.Restock.ClickDetector.MouseClick:Connect(function(player)
  1019.                 if plr.Character:FindFirstChild("Box") then
  1020.                     plr.Character:FindFirstChild("Box"):Destroy()
  1021.                     Animations[plr]["Holding Box"]:Stop()
  1022.                     Animations[plr]["Holding Box"] = nil
  1023.                 end
  1024.                 JobRemotes.ActivateClickDetector:FireClient(plr, Restaurant.ClickDetectors.Cooker.Restock.ClickDetector, false)
  1025.                 inStock = true
  1026.                 JobRemotes.ShowArrow:FireClient(plr)
  1027.  
  1028.                 RoleStocks[plr] = 0
  1029.                 connection2:Disconnect()
  1030.             end)
  1031.             table.insert(PlayerConnections[plr], connection2)
  1032.  
  1033.             connection:Disconnect()
  1034.         end)
  1035.         table.insert(PlayerConnections[plr], connection)
  1036.  
  1037.         repeat task.wait()
  1038.             if connection == nil then
  1039.                 break
  1040.             end
  1041.         until inStock
  1042.     end
  1043.  
  1044.     local randomAction = math.random(1, 4)
  1045.  
  1046.     JobRemotes.ShowArrow:FireClient(plr, Restaurant.ClickDetectors.Cooker[randomAction])
  1047.  
  1048.     local connection
  1049.     JobRemotes.ActivateClickDetector:FireClient(plr, Restaurant.ClickDetectors.Cooker[randomAction].ClickDetector, true)
  1050.     connection = Restaurant.ClickDetectors.Cooker[randomAction].ClickDetector.MouseClick:Connect(function(player)
  1051.         if player ~= plr then return end
  1052.  
  1053.         local Pan = Restaurant.ClickDetectors.Cooker.Pan
  1054.         local Fryer =  Restaurant.ClickDetectors.Cooker.Fryer
  1055.         local Stove = Restaurant.ClickDetectors.Cooker.Stove
  1056.  
  1057.         JobRemotes.ActivateClickDetector:FireClient(plr, Pan.ClickDetector, true)
  1058.         JobRemotes.ActivateClickDetector:FireClient(plr, Fryer.ClickDetector, true)
  1059.         JobRemotes.ActivateClickDetector:FireClient(plr, Stove.ClickDetector, true)
  1060.  
  1061.         if randomAction == 1 then -- Chicken
  1062.             JobRemotes.ShowArrow:FireClient(plr, Fryer)
  1063.  
  1064.             local connection
  1065.             connection = Fryer.ClickDetector.MouseClick:Connect(function(player)
  1066.                 if player ~= plr then return end
  1067.  
  1068.                 Fryer.Smoke.Enabled = true
  1069.  
  1070.                 -- Disable ClickDetectors
  1071.                 JobRemotes.ActivateClickDetector:FireClient(plr, Pan.ClickDetector, false)
  1072.                 JobRemotes.ActivateClickDetector:FireClient(plr, Fryer.ClickDetector, false)
  1073.                 JobRemotes.ActivateClickDetector:FireClient(plr, Stove.ClickDetector, false)
  1074.  
  1075.                 task.wait(3)
  1076.                 Fryer.Smoke.Enabled = false
  1077.                 connection:Disconnect()
  1078.                 RestaurantJob:Pay(plr)
  1079.                 RoleStocks[plr] += 1
  1080.                 CookerAction(table.unpack(pack))
  1081.             end)
  1082.             table.insert(PlayerConnections[plr], connection)
  1083.         elseif randomAction == 2 then -- Breakfast
  1084.             JobRemotes.ShowArrow:FireClient(plr, Pan)
  1085.             local connection
  1086.             connection = Pan.ClickDetector.MouseClick:Connect(function(player)
  1087.                 if player ~= plr then return end
  1088.  
  1089.                 Pan.Smoke.Enabled = true
  1090.  
  1091.                 -- Disable ClickDetectors
  1092.                 JobRemotes.ActivateClickDetector:FireClient(plr, Pan.ClickDetector, false)
  1093.                 JobRemotes.ActivateClickDetector:FireClient(plr, Fryer.ClickDetector, false)
  1094.                 JobRemotes.ActivateClickDetector:FireClient(plr, Stove.ClickDetector, false)
  1095.  
  1096.                 task.wait(3)
  1097.                 Pan.Smoke.Enabled = false
  1098.                 connection:Disconnect()
  1099.                 RestaurantJob:Pay(plr)
  1100.                 RoleStocks[plr] += 1
  1101.                 CookerAction(table.unpack(pack))
  1102.             end)
  1103.             table.insert(PlayerConnections[plr], connection)
  1104.         elseif randomAction == 3 then -- Sandwich
  1105.             JobRemotes.ShowArrow:FireClient(plr, Stove)
  1106.             local connection
  1107.             connection = Stove.ClickDetector.MouseClick:Connect(function(player)
  1108.                 if player ~= plr then return end
  1109.  
  1110.                 Stove.Smoke.Enabled = true
  1111.  
  1112.                 -- Disable ClickDetectors
  1113.                 JobRemotes.ActivateClickDetector:FireClient(plr, Pan.ClickDetector, false)
  1114.                 JobRemotes.ActivateClickDetector:FireClient(plr, Fryer.ClickDetector, false)
  1115.                 JobRemotes.ActivateClickDetector:FireClient(plr, Stove.ClickDetector, false)
  1116.  
  1117.                 task.wait(3)
  1118.                 Stove.Smoke.Enabled = false
  1119.                 connection:Disconnect()
  1120.                 RestaurantJob:Pay(plr)
  1121.                 RoleStocks[plr] += 1
  1122.                 CookerAction(table.unpack(pack))
  1123.             end)
  1124.             table.insert(PlayerConnections[plr], connection)
  1125.         elseif randomAction == 4 then -- Fish
  1126.             JobRemotes.ShowArrow:FireClient(plr, Pan)
  1127.             local connection
  1128.             connection = Pan.ClickDetector.MouseClick:Connect(function(player)
  1129.                 if player ~= plr then return end
  1130.  
  1131.                 Pan.Smoke.Enabled = true
  1132.                 JobRemotes.ShowArrow:FireClient(plr, Fryer)
  1133.                 local connection2
  1134.                 connection2 = Fryer.ClickDetector.MouseClick:Connect(function(player)
  1135.                     if player ~= plr then return end
  1136.  
  1137.                     Fryer.Smoke.Enabled = true
  1138.  
  1139.                     -- Disable ClickDetectors
  1140.                     JobRemotes.ActivateClickDetector:FireClient(plr, Pan.ClickDetector, false)
  1141.                     JobRemotes.ActivateClickDetector:FireClient(plr, Fryer.ClickDetector, false)
  1142.                     JobRemotes.ActivateClickDetector:FireClient(plr, Stove.ClickDetector, false)
  1143.  
  1144.                     task.wait(3)
  1145.                     Fryer.Smoke.Enabled = false
  1146.                     connection2:Disconnect()
  1147.                     RestaurantJob:Pay(plr)
  1148.                     RoleStocks[plr] += 1
  1149.                     CookerAction(table.unpack(pack))
  1150.                 end)
  1151.  
  1152.                 task.wait(3)
  1153.                 Pan.Smoke.Enabled = false
  1154.                 connection:Disconnect()
  1155.                 table.insert(PlayerConnections[plr], connection2)
  1156.             end)
  1157.             table.insert(PlayerConnections[plr], connection)
  1158.         end
  1159.  
  1160.         JobRemotes.ActivateClickDetector:FireClient(plr, Restaurant.ClickDetectors.Cooker[randomAction].ClickDetector, false)
  1161.         connection:Disconnect()
  1162.     end)
  1163.     table.insert(PlayerConnections[plr], connection)
  1164. end
  1165.  
  1166. local MaxRestock = 2
  1167. function ChopperAction(...)
  1168.     local pack = table.pack(...)
  1169.     local JobName = pack[1]
  1170.     local EventName = pack[2]
  1171.     local plr: Player = pack[3]
  1172.     local station = pack[4]
  1173.     if not HasJob(plr) then return end
  1174.  
  1175.     local inStock = true
  1176.  
  1177.     if RoleStocks[plr] >= MaxRestock then
  1178.         plr.Character.Humanoid.WalkSpeed = 16
  1179.         plr.Character.Humanoid.JumpPower = 7.2
  1180.  
  1181.         inStock = false
  1182.         JobRemotes.ActivateClickDetector:FireClient(plr, Restaurant.Restaurant.ChoppingRestock.ClickDetector, true)
  1183.         JobRemotes.ShowArrow:FireClient(plr, Restaurant.Restaurant.ChoppingRestock)
  1184.         local connection0
  1185.         connection0 = Restaurant.Restaurant.ChoppingRestock.ClickDetector.MouseClick:Connect(function(player)
  1186.             if plr ~= player then return end
  1187.  
  1188.             local Box = game.ReplicatedStorage.Tools["Restaurant"].Box:Clone()
  1189.             Box.Parent = player.Character
  1190.             Box.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, 1)
  1191.  
  1192.             local Weld = Instance.new("Weld", Box)
  1193.             Weld.Part0 = Box
  1194.             Weld.Part1 = player.Character.HumanoidRootPart
  1195.             Weld.C0 = Box.CFrame:Inverse() * player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, 2)
  1196.  
  1197.             local anim = game.ReplicatedStorage.Animations.HoldBox
  1198.             Animations[plr]["Holding Box"] = player.Character.Humanoid.Animator:LoadAnimation(anim)
  1199.             Animations[plr]["Holding Box"]:Play()
  1200.  
  1201.             JobRemotes.ShowArrow:FireClient(plr, Restaurant.Restaurant.RestockPlace)
  1202.  
  1203.             JobRemotes.ActivateClickDetector:FireClient(plr, Restaurant.Restaurant.RestockPlace.ClickDetector, true)
  1204.             Restaurant.Restaurant.RestockPlace.CanQuery = true
  1205.  
  1206.             local connection2
  1207.             connection2 = Restaurant.Restaurant.RestockPlace.ClickDetector.MouseClick:Connect(function(player)
  1208.                 if plr.Character:FindFirstChild("Box") then
  1209.                     plr.Character:FindFirstChild("Box"):Destroy()
  1210.                     Animations[plr]["Holding Box"]:Stop()
  1211.                     Animations[plr]["Holding Box"] = nil
  1212.                 end
  1213.                 inStock = true
  1214.                 JobRemotes.ShowArrow:FireClient(plr)
  1215.                 JobRemotes.ActivateClickDetector:FireClient(plr, Restaurant.Restaurant.RestockPlace.ClickDetector, false)
  1216.                 RoleStocks[plr] = 0
  1217.                 connection2:Disconnect()
  1218.             end)
  1219.             table.insert(PlayerConnections[plr], connection2)
  1220.  
  1221.             connection0:Disconnect()
  1222.         end)
  1223.         table.insert(PlayerConnections[plr], connection0)
  1224.  
  1225.         repeat task.wait()
  1226.             if connection0 == nil then
  1227.                 break
  1228.             end
  1229.         until inStock
  1230.     end
  1231.  
  1232.     Restaurant.Restaurant.RestockPlace.CanQuery = false
  1233.     plr.Character.Humanoid.WalkSpeed = 0
  1234.     plr.Character.Humanoid.JumpPower = 0
  1235.     plr.Character.HumanoidRootPart.CFrame = Restaurant.ChopperItems["Stand"..station].CFrame * CFrame.new(0,1,0)
  1236.  
  1237.     local Board = Restaurant.ClickDetectors.Chopper["Board"..station]
  1238.     local Knife = Restaurant.ClickDetectors.Chopper["Knife"..station]
  1239.  
  1240.     local BoardItem = Restaurant.ChopperItems["Board"..station]
  1241.     local KnifeItem = Restaurant.ChopperItems["Knife"..station]
  1242.  
  1243.     local randomNum = math.random(1, 4)
  1244.  
  1245.     local food
  1246.     local plate
  1247.     if randomNum == 1 then
  1248.         food = Restaurant.ChopperItems["C".. station]
  1249.         plate = Restaurant.ClickDetectors.Chopper["C".. station]
  1250.     elseif randomNum == 2 then
  1251.         food = Restaurant.ChopperItems["B".. station]
  1252.         plate = Restaurant.ClickDetectors.Chopper["B".. station]
  1253.     elseif randomNum == 3 then
  1254.         food = Restaurant.ChopperItems["H".. station]
  1255.         plate = Restaurant.ClickDetectors.Chopper["H".. station]
  1256.     elseif randomNum == 4 then
  1257.         food = Restaurant.ChopperItems["F".. station]
  1258.         plate = Restaurant.ClickDetectors.Chopper["F".. station]
  1259.     end
  1260.  
  1261.     if food and plate then
  1262.         JobRemotes.ShowArrow:FireClient(plr, Board)
  1263.  
  1264.         local connection
  1265.         local connection2
  1266.         local connection3
  1267.  
  1268.         -- Steps/Process
  1269.         local clicks = {
  1270.             first = false,
  1271.             second = false,
  1272.             third = false
  1273.         }
  1274.  
  1275.         JobRemotes.ActivateClickDetector:FireClient(plr, Board.ClickDetector, true)
  1276.         JobRemotes.ActivateClickDetector:FireClient(plr, plate.ClickDetector, true)
  1277.         JobRemotes.ActivateClickDetector:FireClient(plr, Knife.ClickDetector, true)
  1278.  
  1279.         connection = Board.ClickDetector.MouseClick:Connect(function(player)
  1280.             if player ~= plr then return end
  1281.  
  1282.             BoardItem.Transparency = 0
  1283.             JobRemotes.ShowArrow:FireClient(plr, plate)
  1284.  
  1285.             clicks.first = true
  1286.             connection:Disconnect()
  1287.         end)
  1288.  
  1289.         connection2 = plate.ClickDetector.MouseClick:Connect(function(player)
  1290.             if player ~= plr then return end
  1291.             if not clicks.first then return end
  1292.  
  1293.             changeModelTranparency(food, 0)
  1294.             JobRemotes.ShowArrow:FireClient(plr, Knife)
  1295.  
  1296.             clicks.second = true
  1297.             connection2:Disconnect()
  1298.         end)
  1299.  
  1300.         connection3 = Knife.ClickDetector.MouseClick:Connect(function(player)
  1301.             if player ~= plr then return end
  1302.             if not clicks.second then return end
  1303.  
  1304.             changeTransparency(KnifeItem, 0, "Part")
  1305.  
  1306.             local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 3, true)
  1307.             local tween = TweenService:Create(KnifeItem.PrimaryPart, tweenInfo, {
  1308.                 CFrame = (KnifeItem.PrimaryPart.CFrame * CFrame.Angles(math.rad(10), 0, 0)) * CFrame.new(-2, 0, 0)
  1309.             })
  1310.  
  1311.             local anim = game.ReplicatedStorage.Animations.Restaurant.Chopping
  1312.             Animations[player]["Chopping Animation"] = player.Character.Humanoid.Animator:LoadAnimation(anim)
  1313.             Animations[player]["Chopping Animation"]:Play()
  1314.  
  1315.             tween:Play()
  1316.  
  1317.  
  1318.             tween.Completed:Wait()
  1319.             Animations[player]["Chopping Animation"]:Stop()
  1320.             Animations[player]["Chopping Animation"] = nil
  1321.  
  1322.             changeModelTranparency(KnifeItem, 1)
  1323.             changeModelTranparency(food, 1)
  1324.             BoardItem.Transparency = 1
  1325.  
  1326.             RestaurantJob:Pay(plr)
  1327.             RoleStocks[plr] += 1
  1328.  
  1329.             ChopperAction(table.unpack(pack))
  1330.  
  1331.             clicks.third = true
  1332.             connection3:Disconnect()
  1333.         end)
  1334.  
  1335.         table.insert(PlayerConnections[plr], connection)
  1336.         table.insert(PlayerConnections[plr], connection2)
  1337.         table.insert(PlayerConnections[plr], connection3)
  1338.     end
  1339. end
  1340.  
  1341. local MaxStock = 7
  1342. function FlavorPickerAction(...)
  1343.     local pack = table.pack(...)
  1344.     local JobName = pack[1]
  1345.     local EventName = pack[2]
  1346.     local plr = pack[3]
  1347.     local station = pack[4]
  1348.     if not HasJob(plr) then return end
  1349.  
  1350.     local inStock = true
  1351.    
  1352.     JobRemotes.FlavorsTransparency:FireClient(plr, IceCream["Ice cream shop"].Flavs.Flavors:GetChildren(), RoleStocks[plr] / MaxStock)
  1353.  
  1354.     JobRemotes.ActivateClickDetector:FireClient(plr, IceCream.ClickDetectors.IceCreamStock.ClickDetector, false)
  1355.  
  1356.     if RoleStocks[plr] == MaxStock then
  1357.         inStock = false
  1358.         print("I am here")
  1359.         JobRemotes.HighlightItem:FireClient(plr, IceCream.ClickDetectors.Boxes)
  1360.         JobRemotes.ShowArrow:FireClient(plr, IceCream.ClickDetectors.Boxes)
  1361.         local connection
  1362.         JobRemotes.ActivateClickDetector:FireClient(plr, IceCream.ClickDetectors.Boxes.ClickDetector, true)
  1363.         connection = IceCream.ClickDetectors.Boxes.ClickDetector.MouseClick:Connect(function(player)
  1364.             if player ~= player then return end
  1365.  
  1366.             local boxDist = 1
  1367.  
  1368.             local Box = game.ReplicatedStorage.Tools["Ice Cream"].Box:Clone()
  1369.             Box.Parent = player.Character
  1370.             Box.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, boxDist)
  1371.  
  1372.             local Weld = Instance.new("Weld", Box)
  1373.             Weld.Part0 = Box
  1374.             Weld.Part1 = player.Character.HumanoidRootPart
  1375.             Weld.C0 = Box.CFrame:Inverse() * player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, boxDist)
  1376.  
  1377.             local anim = game.ReplicatedStorage.Animations.HoldBox
  1378.             Animations[plr]["Holding Box"] = player.Character.Humanoid.Animator:LoadAnimation(anim)
  1379.             Animations[plr]["Holding Box"]:Play()
  1380.  
  1381.             JobRemotes.HighlightItem:FireClient(plr, IceCream.ClickDetectors.IceCreamStock)
  1382.             JobRemotes.ShowArrow:FireClient(plr, IceCream.ClickDetectors.IceCreamStock)
  1383.             JobRemotes.ActivateClickDetector:FireClient(plr, IceCream.ClickDetectors.IceCreamStock.ClickDetector, true)
  1384.  
  1385.             local connection2
  1386.             connection2 = IceCream.ClickDetectors.IceCreamStock.ClickDetector.MouseClick:Connect(function(player)
  1387.                 if plr.Character:FindFirstChild("Box") then
  1388.                     plr.Character:FindFirstChild("Box"):Destroy()
  1389.                     Animations[plr]["Holding Box"]:Stop()
  1390.                     Animations[plr]["Holding Box"] = nil
  1391.                 end
  1392.                 JobRemotes.ActivateClickDetector:FireClient(plr, IceCream.ClickDetectors.IceCreamStock.ClickDetector, false)
  1393.                 inStock = true
  1394.                 JobRemotes.HighlightItem:FireClient(plr)
  1395.                 JobRemotes.ShowArrow:FireClient(plr)
  1396.  
  1397.                 RoleStocks[plr] = 0
  1398.                 connection2:Disconnect()
  1399.             end)
  1400.             table.insert(PlayerConnections[plr], connection2)
  1401.  
  1402.             connection:Disconnect()
  1403.         end)
  1404.  
  1405.         table.insert(PlayerConnections[plr], connection)
  1406.  
  1407.         repeat task.wait()
  1408.             if connection == nil then
  1409.                 break
  1410.             end
  1411.         until inStock
  1412.     end
  1413.  
  1414.  
  1415.     if inStock == true then
  1416.         JobRemotes.FlavorsTransparency:FireClient(plr, IceCream["Ice cream shop"].Flavs.Flavors:GetChildren(), RoleStocks[plr] / MaxStock)
  1417.        
  1418.        
  1419.         local CustomerModels = game.ReplicatedStorage.Customers:GetChildren()
  1420.         local Customer = CustomerModels[math.random(1, #CustomerModels)]:Clone()
  1421.         Customer.Parent = workspace.JobSystem.PlayerCustomers
  1422.  
  1423.         for i, v: BasePart in pairs(Customer:GetDescendants()) do
  1424.             if v:IsA("BasePart") then
  1425.                 v.CollisionGroup = "Customers"
  1426.             end
  1427.         end
  1428.  
  1429.         local Host = Instance.new("ObjectValue", Customer)
  1430.         Host.Name = "Host"
  1431.         Host.Value = plr
  1432.  
  1433.         local Humanoid: Humanoid = Customer.Humanoid
  1434.  
  1435.         local Waypoints = IceCream.Waypoints.FlavorPicker["FP"..station]
  1436.  
  1437.         Customer.HumanoidRootPart.CFrame = Waypoints:FindFirstChild("1").CFrame
  1438.         CreatePath(Customer, Waypoints:FindFirstChild("5").Position)
  1439.  
  1440.         local suffix = ListOfCustomerMsgs.Suffix[JobName][math.random(1, #ListOfCustomerMsgs.Suffix[JobName])]
  1441.  
  1442.         local CustomerTag = script.CustomerTag:Clone()
  1443.         CustomerTag.Parent = Customer.Head
  1444.  
  1445.         CustomerTag.Frame.Icon.Image = suffix.Icon
  1446.  
  1447.         for i = 1, #IceCream.ClickDetectors.FlavorPicker:GetChildren() do
  1448.             local flavor = IceCream.ClickDetectors.FlavorPicker:FindFirstChild(i)
  1449.  
  1450.             if flavor then
  1451.                 local connection
  1452.                 JobRemotes.ActivateClickDetector:FireClient(plr, flavor.ClickDetector, true)
  1453.                 connection = flavor.ClickDetector.MouseClick:Connect(function(player)
  1454.                     if player ~= plr then return end
  1455.                    
  1456.                     local PHum = plr.Character:WaitForChild("Humanoid")
  1457.                    
  1458.                     local Animation = game:GetService("ReplicatedStorage").Animations["Ice Cream"].Picking
  1459.                     local PlayAni = PHum:WaitForChild("Animator"):LoadAnimation(Animation)
  1460.                     PlayAni:Play()
  1461.                    
  1462.                     connection:Disconnect()
  1463.                     CustomerTag:Destroy()
  1464.                    
  1465.                     if tonumber(i) == tonumber(suffix.Order) then
  1466.                         if Customer:FindFirstChild("Head") == nil then return end
  1467.                         ChatService:Chat(Customer:WaitForChild("Head"), "Thanks for the Ice Cream 🍦!!", Enum.ChatColor.White)
  1468.                         IceCreamJob:Pay(plr)
  1469.  
  1470.                         task.wait(1)
  1471.                         Customer:Destroy()
  1472.                         print("Customer Destroyed1")
  1473.  
  1474.                         coroutine.wrap(function()
  1475.                             FlavorPickerAction(table.unpack(pack))
  1476.                         end)()
  1477.                     else
  1478.                         if Customer:FindFirstChild("Head") == nil then return end
  1479.                         ChatService:Chat(Customer:WaitForChild("Head"), "Ugh, you got my order wrong!!", Enum.ChatColor.White)
  1480.  
  1481.                         task.wait(1)
  1482.                         Customer:Destroy()
  1483.                         print("Customer Destroyed2")
  1484.  
  1485.                         coroutine.wrap(function()
  1486.                             FlavorPickerAction(table.unpack(pack))
  1487.                         end)()
  1488.                     end
  1489.                     RoleStocks[plr] += 1--ERRRRROOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOORRRRRRRRRRRRR
  1490.                 end)
  1491.  
  1492.                 table.insert(PlayerConnections[plr], connection)
  1493.             end
  1494.         end
  1495.     end
  1496. end
  1497.  
  1498. local MaxStock = 7
  1499. function ToppingsPickerAction(...)
  1500.     print('Toppings')
  1501.     local pack = table.pack(...)
  1502.     local JobName = pack[1]
  1503.     local EventName = pack[2]
  1504.     local plr = pack[3]
  1505.     local station = pack[4]
  1506.     if not HasJob(plr) then return end
  1507.  
  1508.     JobRemotes.ActivateClickDetector:FireClient(plr, IceCream.ClickDetectors.ToppingsStock.ClickDetector, false)
  1509.  
  1510.     local inStock = true
  1511.  
  1512.     if RoleStocks[plr] >= MaxStock then
  1513.         inStock = false
  1514.         JobRemotes.ActivateClickDetector:FireClient(plr, IceCream.ClickDetectors.Toppings.ClickDetector, true)
  1515.         JobRemotes.ShowArrow:FireClient(plr, IceCream.ClickDetectors.Toppings)
  1516.         local connection
  1517.         connection = IceCream.ClickDetectors.Toppings.ClickDetector.MouseClick:Connect(function(player)
  1518.             if player ~= plr then return end
  1519.            
  1520.             local PHum = plr.Character:WaitForChild("Humanoid")
  1521.            
  1522.             local Animation = game:GetService("ReplicatedStorage").Animations["Ice Cream"].Picking
  1523.             local PlayAni = PHum:WaitForChild("Animator"):LoadAnimation(Animation)
  1524.             PlayAni:Play()
  1525.            
  1526.             local boxDist = 1
  1527.  
  1528.             local Box = game.ReplicatedStorage.Tools["Ice Cream"].Box:Clone()
  1529.             Box.Parent = player.Character
  1530.             Box.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, boxDist)
  1531.  
  1532.             local Weld = Instance.new("Weld", Box)
  1533.             Weld.Part0 = Box
  1534.             Weld.Part1 = player.Character.HumanoidRootPart
  1535.             Weld.C0 = Box.CFrame:Inverse() * player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, boxDist)
  1536.  
  1537.             local anim = game.ReplicatedStorage.Animations.HoldBox
  1538.             Animations[plr]["Holding Box"] = player.Character.Humanoid.Animator:LoadAnimation(anim)
  1539.             Animations[plr]["Holding Box"]:Play()
  1540.  
  1541.             JobRemotes.ShowArrow:FireClient(plr, IceCream.ClickDetectors.ToppingsStock)
  1542.  
  1543.             JobRemotes.ActivateClickDetector:FireClient(plr, IceCream.ClickDetectors.ToppingsStock.ClickDetector, true)
  1544.  
  1545.             local connection2
  1546.             connection2 = IceCream.ClickDetectors.ToppingsStock.ClickDetector.MouseClick:Connect(function(player)
  1547.                 if plr.Character:FindFirstChild("Box") then
  1548.                     plr.Character:FindFirstChild("Box"):Destroy()
  1549.                     Animations[plr]["Holding Box"]:Stop()
  1550.                     Animations[plr]["Holding Box"] = nil
  1551.                 end
  1552.                 inStock = true
  1553.                 JobRemotes.ShowArrow:FireClient(plr)
  1554.                 JobRemotes.ActivateClickDetector:FireClient(plr, IceCream.ClickDetectors.ToppingsStock.ClickDetector, false)
  1555.                 RoleStocks[plr] = 0
  1556.                 connection2:Disconnect()
  1557.             end)
  1558.             table.insert(PlayerConnections[plr], connection2)
  1559.  
  1560.             connection:Disconnect()
  1561.         end)
  1562.         table.insert(PlayerConnections[plr], connection)
  1563.  
  1564.         repeat task.wait()
  1565.             if connection == nil then
  1566.                 break
  1567.             end
  1568.         until inStock
  1569.     end
  1570.  
  1571.     if inStock == true then
  1572.         print(inStock)
  1573.         print(RoleStocks[plr])
  1574.         local Customer: Model = game.ReplicatedStorage.Customers:GetChildren()
  1575.         Customer = Customer[math.random(1, #Customer)]:Clone()
  1576.         Customer.Parent = workspace.JobSystem.PlayerCustomers
  1577.  
  1578.         for i, v: BasePart in pairs(Customer:GetDescendants()) do
  1579.             if v:IsA("BasePart") then
  1580.                 v.CollisionGroup = "Customers"
  1581.             end
  1582.         end
  1583.  
  1584.         local Host = Instance.new("ObjectValue", Customer)
  1585.         Host.Name = "Host"
  1586.         Host.Value = plr
  1587.  
  1588.         local Humanoid: Humanoid = Customer.Humanoid
  1589.  
  1590.         local Waypoints = IceCream.Waypoints.ToppingsPicker["TP"..station]
  1591.  
  1592.         Customer.HumanoidRootPart.CFrame = Waypoints:FindFirstChild("1").CFrame
  1593.         CreatePath(Customer, Waypoints:FindFirstChild("5").Position)
  1594.  
  1595.  
  1596.         local num = math.random(1, #ListOfCustomerMsgs.Suffix[JobName])
  1597.         local suffix = ListOfCustomerMsgs.Suffix[JobName][num]
  1598.         local Order = Orders.Clone(Orders.IceCream.Order[num])
  1599.  
  1600.         local CustomerTag = script.CustomerTag:Clone()
  1601.         CustomerTag.Parent = Customer:WaitForChild('Head')
  1602.  
  1603.         CustomerTag.Frame.Icon.Image = suffix.Icon
  1604.  
  1605.         local isRunning = true
  1606.         local isOnNumber = 1
  1607.         local NameOfStage = ""
  1608.  
  1609.         for i, v in pairs(IceCream.ClickDetectors.ToppingsPicker:GetChildren()) do
  1610.             local isCorrect = false -- whether it is on the recipe
  1611.             for j, k in pairs(Order.Clicks) do
  1612.                 if k.Name == v.Name then
  1613.                     isCorrect = true
  1614.                 end
  1615.             end
  1616.  
  1617.             if not isCorrect then
  1618.                 local connection
  1619.                 JobRemotes.ActivateClickDetector:FireClient(plr, v.ClickDetector, true)
  1620.                 connection = v.ClickDetector.MouseClick:Connect(function(player)
  1621.                     if player ~= plr then return end
  1622.                     if Customer:FindFirstChild('Head') == nil then
  1623.                         return
  1624.                     end
  1625.  
  1626.                     CustomerTag:Destroy()
  1627.                     ChatService:Chat(Customer:WaitForChild('Head'), "Ugh, you got my order wrong!!", Enum.ChatColor.White)
  1628.                     connection:Disconnect()
  1629.                     task.wait(1)
  1630.                     Customer:Destroy()
  1631.  
  1632.                     isRunning = false
  1633.  
  1634.                     RoleStocks[plr] += 1
  1635.                     ToppingsPickerAction(table.unpack(pack))
  1636.                 end)
  1637.                 table.insert(PlayerConnections[plr], connection)
  1638.             end
  1639.         end
  1640.  
  1641.         for i = 1, #Order.Clicks, 1 do
  1642.             local Stage = Order.Clicks[i]
  1643.             local v = IceCream.ClickDetectors.ToppingsPicker[Stage.Name]
  1644.             local connection
  1645.  
  1646.             if i == 1 then
  1647.                 JobRemotes.ShowArrow:FireClient(plr, v)
  1648.             end
  1649.             JobRemotes.ActivateClickDetector:FireClient(plr, v.ClickDetector, true)
  1650.             connection = v.ClickDetector.MouseClick:Connect(function(player)
  1651.                 if player ~= plr then return end
  1652.  
  1653.                 if i ~= 1 then
  1654.                     local clminus = Order.Clicks[i - 1] -- Current one minus 1 (to go back)
  1655.                     if clminus then
  1656.                         if not clminus.Done then
  1657.                             isRunning = false
  1658.                             ToppingsPickerAction(table.unpack(pack))
  1659.                             connection:Disconnect()
  1660.                             return
  1661.                         end
  1662.                     end
  1663.                 end
  1664.  
  1665.                 connection:Disconnect()
  1666.  
  1667.                 isOnNumber += 1
  1668.                 if i ~= #Order.Clicks then
  1669.                     NameOfStage = Order.Clicks[i+1].Name
  1670.                 end
  1671.                 print(i)
  1672.                 if i == #Order.Clicks then
  1673.                     JobRemotes.ShowArrow:FireClient(plr)
  1674.                     isRunning = false
  1675.                     RoleStocks[plr] += 1
  1676.                     CustomerTag:Destroy()
  1677.                     IceCreamJob:Pay(plr)
  1678.                     if Customer:FindFirstChild('Head') ~= nil then
  1679.                         ChatService:Chat(Customer.Head, "Thanks for the Ice Cream 🍦!!", Enum.ChatColor.White)
  1680.                     end
  1681.  
  1682.                     task.wait(1)
  1683.                     Customer:Destroy()
  1684.                     ToppingsPickerAction(table.unpack(pack))
  1685.                 end
  1686.                 Order.Clicks[i].Done = true
  1687.             end)
  1688.             table.insert(PlayerConnections[plr], connection)
  1689.         end
  1690.  
  1691.         coroutine.wrap(function()
  1692.             while isRunning do
  1693.                 if #PlayerConnections[plr] == 0 then
  1694.                     break
  1695.                 end
  1696.  
  1697.                 if isOnNumber ~= 1 then
  1698.                     JobRemotes.ShowArrow:FireClient(plr, IceCream.ClickDetectors.ToppingsPicker[NameOfStage])
  1699.                 end
  1700.                 task.wait()
  1701.             end
  1702.             RoleStocks[plr] += 1
  1703.         end)()
  1704.     end
  1705. end
  1706.  
  1707. function QuitJob(...)
  1708.     local pack = table.pack(...)
  1709.     local JobName = pack[1]
  1710.     local EventName = pack[2]
  1711.     local plr = pack[3]
  1712.     if not HasJob(plr) then return end
  1713.    
  1714.     JobRemotes.FlavorsTransparency:FireClient(plr, IceCream["Ice cream shop"].Flavs.Flavors:GetChildren(), 0)
  1715.  
  1716.     local pay = 0
  1717.     local memo = ""
  1718.  
  1719.     if JobName == HallaPizzaJob.JobName then
  1720.         -- Paycheck
  1721.         pay = HallaPizzaJob:GetPlayerPay(plr)
  1722.         memo = "HP WORKER"
  1723.  
  1724.         HallaPizzaJob.RemoveWorker(plr)
  1725.         local Registers = HallaPizza.Registers
  1726.  
  1727.         -- Reset Registers if they are a Cashier
  1728.         if Registers.Register1.Owner.Value == plr then
  1729.             Registers.Register1.Owner.Value = nil
  1730.         elseif Registers.Register2.Owner.Value == plr then
  1731.             Registers.Register2.Owner.Value = nil
  1732.         end
  1733.  
  1734.         local DM = HallaPizza.ObjectValues.DoughMaker -- Dough Maker Object Values
  1735.         local DMC = HallaPizza.ClickDetectors.DoughMaker -- Dough Maker ClickDetectors
  1736.  
  1737.         if DM.Table1.Host.Value == plr then
  1738.             DM.Table1.Host.Value = nil
  1739.             JobRemotes.ActivateClickDetector:FireClient(plr, DMC.Table1.ClickDetector, false)
  1740.         elseif DM.Table2.Host.Value == plr then
  1741.             DM.Table2.Host.Value = nil
  1742.             JobRemotes.ActivateClickDetector:FireClient(plr, DMC.Table2.ClickDetector, false)
  1743.         end
  1744.  
  1745.         local PM = HallaPizza.ObjectValues.PizzaMaker -- Pizza Maker Object Values
  1746.         local PMC = HallaPizza.ClickDetectors.PizzaMaker -- Pizza Maker ClickDetectors
  1747.         local PMI = HallaPizza.PizzaMakerItems
  1748.  
  1749.         if PM.Table1.Host.Value == plr then
  1750.             PM.Table1.Host.Value = nil
  1751.             PM.Screen1.Value.GUI.Icon.Image = ""
  1752.             JobRemotes.ActivateClickDetector:FireClient(plr, PMC.Table1.ClickDetector, false)
  1753.             changeModelTranparency(PMI.Pizza1, 1)
  1754.         elseif PM.Table2.Host.Value == plr then
  1755.             PM.Table2.Host.Value = nil
  1756.             PM.Screen2.Value.GUI.Icon.Image = ""
  1757.             JobRemotes.ActivateClickDetector:FireClient(plr, PMC.Table2.ClickDetector, false)
  1758.             changeModelTranparency(PMI.Pizza2, 1)
  1759.         end
  1760.  
  1761.         -- Reset Player Worker Count
  1762.         local workers = HallaPizzaJob:GetRoleTotalWorkers("Cashier")
  1763.         local maxWorkers = HallaPizzaJob:GetRoleMaxWorkers("Cashier")
  1764.         HallaPizza.ClaimParts.CashRegister.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
  1765.  
  1766.         workers = HallaPizzaJob:GetRoleTotalWorkers("Pizza Runner")
  1767.         maxWorkers = HallaPizzaJob:GetRoleMaxWorkers("Pizza Runner")
  1768.         HallaPizza.ClaimParts.PizzaRunner.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
  1769.  
  1770.         local workers = HallaPizzaJob:GetRoleTotalWorkers("Dough Maker")
  1771.         local maxWorkers = HallaPizzaJob:GetRoleMaxWorkers("Dough Maker")
  1772.         HallaPizza.ClaimParts.DoughMaker.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
  1773.  
  1774.         local workers = HallaPizzaJob:GetRoleTotalWorkers("Pizza Maker")
  1775.         local maxWorkers = HallaPizzaJob:GetRoleMaxWorkers("Pizza Maker")
  1776.         HallaPizza.ClaimParts.PizzaMaker.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
  1777.     elseif JobName == RestaurantJob.JobName then
  1778.         -- Paycheck
  1779.         pay = RestaurantJob:GetPlayerPay(plr)
  1780.         memo = "Restaurant Worker"
  1781.  
  1782.         RestaurantJob.RemoveWorker(plr)
  1783.  
  1784.         -- Reset Player Worker Count
  1785.         local workers = RestaurantJob:GetRoleTotalWorkers("Cashier")
  1786.         local maxWorkers = RestaurantJob:GetRoleMaxWorkers("Cashier")
  1787.         Restaurant.ClaimParts.CashRegister.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
  1788.  
  1789.         -- Reset Player Worker Count
  1790.         local workers = RestaurantJob:GetRoleTotalWorkers("Delivery")
  1791.         local maxWorkers = RestaurantJob:GetRoleMaxWorkers("Delivery")
  1792.         Restaurant.ClaimParts.Delivery.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
  1793.  
  1794.         -- Reset Player Worker Count
  1795.         local workers = RestaurantJob:GetRoleTotalWorkers("Dish Washer")
  1796.         local maxWorkers = RestaurantJob:GetRoleMaxWorkers("Dish Washer")
  1797.         Restaurant.ClaimParts.DishWasher.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
  1798.  
  1799.         -- Reset Player Worker Count
  1800.         local workers = RestaurantJob:GetRoleTotalWorkers("Cooker")
  1801.         local maxWorkers = RestaurantJob:GetRoleMaxWorkers("Cooker")
  1802.         Restaurant.ClaimParts.Cooker.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
  1803.        
  1804.         -- Reset Player Worker Count
  1805.         local workers = RestaurantJob:GetRoleTotalWorkers("Chopper")
  1806.         local maxWorkers = RestaurantJob:GetRoleMaxWorkers("Chopper")
  1807.         Restaurant.ClaimParts.Chopper.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
  1808.     elseif JobName == IceCreamJob.JobName then
  1809.         -- Paycheck
  1810.         pay = IceCreamJob:GetPlayerPay(plr)
  1811.         memo = "Ice Cream Worker"
  1812.  
  1813.         IceCreamJob.RemoveWorker(plr)
  1814.  
  1815.         -- Reset Player Worker Count
  1816.         local workers = IceCreamJob:GetRoleTotalWorkers("Flavor Picker")
  1817.         local maxWorkers = IceCreamJob:GetRoleMaxWorkers("Flavor Picker")
  1818.         IceCream.ClaimParts.FlavorPicker.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
  1819.  
  1820.         -- Reset Player Worker Count
  1821.         local workers = IceCreamJob:GetRoleTotalWorkers("Toppings Picker")
  1822.         local maxWorkers = IceCreamJob:GetRoleMaxWorkers("Toppings Picker")
  1823.         IceCream.ClaimParts.ToppingsPicker.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
  1824.  
  1825.         -- Reset Player Worker Count
  1826.         local workers = IceCreamJob:GetRoleTotalWorkers("Cashier")
  1827.         local maxWorkers = IceCreamJob:GetRoleMaxWorkers("Cashier")
  1828.         IceCream.ClaimParts.CashRegister.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
  1829.     end
  1830.     for i, v:ProximityPrompt in pairs(workspace.JobSystem[JobName].ClaimParts:GetDescendants()) do
  1831.         if v:IsA("ProximityPrompt") then
  1832.             JobRemotes.ActivatePrompt:FireClient(plr, v, true)
  1833.         end
  1834.     end
  1835.     local CanReceivePay = true
  1836.     if pay > 0 then
  1837.         JobRemotes.ShowPaycheck:FireClient(plr, pay, memo)
  1838.         JobRemotes.GivePaycheck.OnServerEvent:Connect(function(player)
  1839.             if CanReceivePay == true then
  1840.                 CanReceivePay = false
  1841.                 player.leaderstats:FindFirstChild("Hallabucks").Value += pay
  1842.             end
  1843.            
  1844.         end)
  1845.     end
  1846.  
  1847.     -- Disconnect all RBX Events
  1848.     for i, v in pairs(PlayerConnections[plr]) do
  1849.         v:Disconnect()
  1850.         PlayerConnections[plr][i] = nil
  1851.     end
  1852.  
  1853.     RoleStocks[plr] = 0
  1854.  
  1855.     -- Destroy all Player Customers owned by this player
  1856.     for i, v in pairs(workspace.JobSystem.PlayerCustomers:GetChildren()) do
  1857.         if v:FindFirstChild("Host") then
  1858.             if v:FindFirstChild("Host").Value == plr then
  1859.                 v:Destroy()
  1860.             end
  1861.         end
  1862.     end
  1863.  
  1864.     -- Stop showing an arrow
  1865.     JobRemotes.ShowArrow:FireClient(plr)
  1866.  
  1867.     plr.PlayerGui.CashierGui.Adornee = nil
  1868.     plr.PlayerGui.CashierGui2.Adornee = nil
  1869.  
  1870.     if plr.Character:FindFirstChild("Box") then
  1871.         plr.Character:FindFirstChild("Box"):Destroy()
  1872.         Animations[plr]["Holding Box"]:Stop()
  1873.         Animations[plr]["Holding Box"] = nil
  1874.     end
  1875.  
  1876.     for i, v in pairs(workspace.JobSystem:GetDescendants()) do
  1877.         if v:IsA("ClickDetector") then
  1878.             JobRemotes.ActivateClickDetector:FireClient(plr, v, false)
  1879.         end
  1880.     end
  1881.  
  1882.     plr.Character.Humanoid.WalkSpeed = game.StarterPlayer.CharacterWalkSpeed
  1883.     plr.Character.Humanoid.JumpPower = game.StarterPlayer.CharacterJumpPower
  1884.  
  1885.     JobRemotes.ShowFrames:FireClient(plr, false)
  1886.  
  1887.     if plr.Character:FindFirstChildWhichIsA("Folder") then
  1888.         task.spawn(function()
  1889.             plr.Character:FindFirstChildWhichIsA("Folder"):Destroy()
  1890.         end)
  1891.     end
  1892. end
  1893.  
  1894. -- Create Events
  1895. -- HallaPizza
  1896. HallaPizzaJob:CreateEvent("StartJob", StartJob)
  1897. HallaPizzaJob:CreateEvent("QuitJob", QuitJob)
  1898. HallaPizzaJob:CreateRoleAction("Cashier", "Cashier Customer", CashierCustomerAction)
  1899. HallaPizzaJob:CreateRoleAction("Pizza Runner", "PR Customer", CustomerAction2)
  1900. HallaPizzaJob:CreateRoleAction("Dough Maker", "Dough Maker Action", DoughMakerAction)
  1901. HallaPizzaJob:CreateRoleAction("Pizza Maker", "Pizza Maker Action", PizzaMakerAction)
  1902.  
  1903. -- Restaurant
  1904. RestaurantJob:CreateEvent("StartJob", StartJob)
  1905. --RestaurantJob:CreateEvent("ChangeRole", ChangeRole)
  1906. RestaurantJob:CreateEvent("QuitJob", QuitJob)
  1907. RestaurantJob:CreateRoleAction("Cashier", "Cashier Customer", CashierCustomerAction)
  1908. RestaurantJob:CreateRoleAction("Delivery", "CustomerAction2", CustomerAction2)
  1909. RestaurantJob:CreateRoleAction("Dish Washer", "Dish Washer Action", DishWasherAction)
  1910. RestaurantJob:CreateRoleAction("Cooker", "Cooker Action", CookerAction)
  1911. RestaurantJob:CreateRoleAction("Chopper", "Chopper Action", ChopperAction)
  1912.  
  1913.  
  1914. -- Ice Cream
  1915. IceCreamJob:CreateEvent("StartJob", StartJob)
  1916. --IceCreamJob:CreateEvent("ChangeRole", ChangeRole)
  1917. IceCreamJob:CreateEvent("QuitJob", QuitJob)
  1918. IceCreamJob:CreateRoleAction("Cashier", "Cashier Customer", CashierCustomerAction)
  1919. IceCreamJob:CreateRoleAction("Flavor Picker", "Flavor Picker Action", FlavorPickerAction)
  1920. IceCreamJob:CreateRoleAction("Toppings Picker", "Toppings Picker Action", ToppingsPickerAction)
  1921.  
  1922. ---------------------------------------------------------------
  1923. -- Prompt Events
  1924. ---------------------------------------------------------------
  1925.  
  1926. ---------------------- HallaPizza -----------------------------
  1927.  
  1928. HallaPizza.EndShift.Touched:Connect(function(hit)
  1929.     local player = game.Players:GetPlayerFromCharacter(hit.Parent)
  1930.     if player then
  1931.         HallaPizzaJob:FireEvent("QuitJob", player)
  1932.     end
  1933. end)
  1934.  
  1935. -- Cashier -----------------------------------------------------
  1936.  
  1937. local Registers = HallaPizza.Registers
  1938. HallaPizza.ClaimParts.CashRegister.ProximityPrompt.Triggered:Connect(function(player)
  1939.     HallaPizzaJob:FireEvent("StartJob", player, "Cashier")
  1940.     if Registers.Register1.Owner.Value == nil then
  1941.         Registers.Register1.Owner.Value = player
  1942.     elseif Registers.Register2.Owner.Value == nil then
  1943.         Registers.Register2.Owner.Value = player
  1944.     end
  1945.     local workers = HallaPizzaJob:GetRoleTotalWorkers("Cashier")
  1946.     local maxWorkers = HallaPizzaJob:GetRoleMaxWorkers("Cashier")
  1947.     HallaPizza.ClaimParts.CashRegister.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
  1948.     HallaPizzaJob:FireRoleAction("Cashier", "Cashier Customer", player)
  1949. end)
  1950.  
  1951. -- Pizza Runner -----------------------------------------------
  1952.  
  1953. HallaPizza.ClaimParts.PizzaRunner.ProximityPrompt.Triggered:Connect(function(player)
  1954.     HallaPizzaJob:FireEvent("StartJob", player, "Pizza Runner")
  1955.  
  1956.     local workers = HallaPizzaJob:GetRoleTotalWorkers("Pizza Runner")
  1957.     local maxWorkers = HallaPizzaJob:GetRoleMaxWorkers("Pizza Runner")
  1958.     HallaPizza.ClaimParts.PizzaRunner.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
  1959.  
  1960.     HallaPizzaJob:FireRoleAction("Pizza Runner", "PR Customer", player)
  1961. end)
  1962.  
  1963.  
  1964. -- Dough Maker -----------------------------------------------
  1965.  
  1966. HallaPizza.ClaimParts.DoughMaker.ProximityPrompt.Triggered:Connect(function(player)
  1967.     HallaPizzaJob:FireEvent("StartJob", player, "Dough Maker")
  1968.  
  1969.     local workers = HallaPizzaJob:GetRoleTotalWorkers("Dough Maker")
  1970.     local maxWorkers = HallaPizzaJob:GetRoleMaxWorkers("Dough Maker")
  1971.     HallaPizza.ClaimParts.DoughMaker.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
  1972.  
  1973.     local DM = HallaPizza.ObjectValues.DoughMaker -- Dough Maker Object Values
  1974.     if DM.Table1.Host.Value ~= nil then
  1975.         DM.Table1.Host.Value = player
  1976.     elseif DM.Table2.Host.Value ~= nil then
  1977.         DM.Table2.Host.Value = player
  1978.     end
  1979.  
  1980.     HallaPizzaJob:FireRoleAction("Dough Maker", "Dough Maker Action", player, HallaPizzaJob:GetRoleTotalWorkers("Dough Maker"))
  1981. end)
  1982.  
  1983. -- Pizza Maker -----------------------------------------------
  1984.  
  1985. HallaPizza.ClaimParts.PizzaMaker.ProximityPrompt.Triggered:Connect(function(player)
  1986.     HallaPizzaJob:FireEvent("StartJob", player, "Pizza Maker")
  1987.  
  1988.     local workers = HallaPizzaJob:GetRoleTotalWorkers("Pizza Maker")
  1989.     local maxWorkers = HallaPizzaJob:GetRoleMaxWorkers("Pizza Maker")
  1990.     HallaPizza.ClaimParts.PizzaMaker.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
  1991.  
  1992.     local PM = HallaPizza.ObjectValues.PizzaMaker -- Dough Maker Object Values
  1993.     if PM.Table1.Host.Value == nil then
  1994.         PM.Table1.Host.Value = player
  1995.     elseif PM.Table2.Host.Value == nil then
  1996.         PM.Table2.Host.Value = player
  1997.     end
  1998.  
  1999.     HallaPizzaJob:FireRoleAction("Pizza Maker", "Pizza Maker Action", player, HallaPizzaJob:GetRoleTotalWorkers("Pizza Maker"))
  2000. end)
  2001.  
  2002. ---------------------- Restaurant -----------------------------
  2003.  
  2004. Restaurant.EndShift.Touched:Connect(function(hit)
  2005.     local player = game.Players:GetPlayerFromCharacter(hit.Parent)
  2006.     if player then
  2007.         RestaurantJob:FireEvent("QuitJob", player)
  2008.     end
  2009. end)
  2010.  
  2011. -- Cashier -----------------------------------------------------
  2012.  
  2013. local Registers = Restaurant.Registers
  2014. Restaurant.ClaimParts.CashRegister.ProximityPrompt.Triggered:Connect(function(player)
  2015.     RestaurantJob:FireEvent("StartJob", player, "Cashier")
  2016.     if Registers.Register1.Owner.Value == nil then
  2017.         Registers.Register1.Owner.Value = player
  2018.     elseif Registers.Register2.Owner.Value == nil then
  2019.         Registers.Register2.Owner.Value = player
  2020.     end
  2021.     local workers = RestaurantJob:GetRoleTotalWorkers("Cashier")
  2022.     local maxWorkers = RestaurantJob:GetRoleMaxWorkers("Cashier")
  2023.     Restaurant.ClaimParts.CashRegister.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
  2024.     RestaurantJob:FireRoleAction("Cashier", "Cashier Customer", player)
  2025. end)
  2026.  
  2027. -- Delivery -----------------------------------------------
  2028.  
  2029. Restaurant.ClaimParts.Delivery.ProximityPrompt.Triggered:Connect(function(player)
  2030.     RestaurantJob:FireEvent("StartJob", player, "Delivery")
  2031.  
  2032.     local workers = RestaurantJob:GetRoleTotalWorkers("Delivery")
  2033.     local maxWorkers = RestaurantJob:GetRoleMaxWorkers("Delivery")
  2034.     Restaurant.ClaimParts.Delivery.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
  2035.  
  2036.     RestaurantJob:FireRoleAction("Delivery", "CustomerAction2", player)
  2037. end)
  2038.  
  2039. -- Dish Washer -----------------------------------------------
  2040.  
  2041. Restaurant.ClaimParts.DishWasher.ProximityPrompt.Triggered:Connect(function(player)
  2042.     RestaurantJob:FireEvent("StartJob", player, "Dish Washer")
  2043.  
  2044.     local workers = RestaurantJob:GetRoleTotalWorkers("Dish Washer")
  2045.     local maxWorkers = RestaurantJob:GetRoleMaxWorkers("Dish Washer")
  2046.     Restaurant.ClaimParts.DishWasher.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
  2047.  
  2048.     RestaurantJob:FireRoleAction("Dish Washer", "Dish Washer Action", player, RestaurantJob:GetRoleTotalWorkers("Dish Washer"))
  2049. end)
  2050.  
  2051. -- Cooker -----------------------------------------------
  2052.  
  2053.  
  2054. Restaurant.ClaimParts.Cooker.ProximityPrompt.Triggered:Connect(function(player)
  2055.     RestaurantJob:FireEvent("StartJob", player, "Cooker")
  2056.  
  2057.     local workers = RestaurantJob:GetRoleTotalWorkers("Cooker")
  2058.     local maxWorkers = RestaurantJob:GetRoleMaxWorkers("Cooker")
  2059.     Restaurant.ClaimParts.Cooker.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
  2060.  
  2061.     RestaurantJob:FireRoleAction("Cooker", "Cooker Action", player)
  2062. end)
  2063.  
  2064. -- Chopper -----------------------------------------------
  2065.  
  2066. Restaurant.ClaimParts.Chopper.ProximityPrompt.Triggered:Connect(function(player)
  2067.     RestaurantJob:FireEvent("StartJob", player, "Chopper")
  2068.  
  2069.     local workers = RestaurantJob:GetRoleTotalWorkers("Chopper")
  2070.     local maxWorkers = RestaurantJob:GetRoleMaxWorkers("Chopper")
  2071.     Restaurant.ClaimParts.Chopper.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
  2072.  
  2073.     RestaurantJob:FireRoleAction("Chopper", "Chopper Action", player, RestaurantJob:GetRoleTotalWorkers("Chopper"))
  2074. end)
  2075.  
  2076. ---------------------- Ice Cream Shop -----------------------------
  2077.  
  2078. IceCream.EndShift.Touched:Connect(function(hit)
  2079.     local player = game.Players:GetPlayerFromCharacter(hit.Parent)
  2080.     if player then
  2081.         IceCreamJob:FireEvent("QuitJob", player)
  2082.     end
  2083. end)
  2084.  
  2085. -- Cashier -----------------------------------------------------
  2086.  
  2087. local Registers = IceCream.Registers
  2088. IceCream.ClaimParts.CashRegister.ProximityPrompt.Triggered:Connect(function(player)
  2089.     IceCreamJob:FireEvent("StartJob", player, "Cashier")
  2090.     if Registers.Register1.Owner.Value == nil then
  2091.         Registers.Register1.Owner.Value = player
  2092.     elseif Registers.Register2.Owner.Value == nil then
  2093.         Registers.Register2.Owner.Value = player
  2094.     end
  2095.     local workers = IceCreamJob:GetRoleTotalWorkers("Cashier")
  2096.     local maxWorkers = IceCreamJob:GetRoleMaxWorkers("Cashier")
  2097.     IceCream.ClaimParts.CashRegister.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
  2098.     IceCreamJob:FireRoleAction("Cashier", "Cashier Customer", player)
  2099. end)
  2100.  
  2101. IceCream.ClaimParts.FlavorPicker.ProximityPrompt.Triggered:Connect(function(player)
  2102.     IceCreamJob:FireEvent("StartJob", player, "Flavor Picker")
  2103.  
  2104.     local workers = IceCreamJob:GetRoleTotalWorkers("Flavor Picker")
  2105.     local maxWorkers = IceCreamJob:GetRoleMaxWorkers("Flavor Picker")
  2106.     IceCream.ClaimParts.FlavorPicker.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
  2107.     IceCreamJob:FireRoleAction("Flavor Picker", "Flavor Picker Action", player, IceCreamJob:GetRoleTotalWorkers("Flavor Picker"))
  2108. end)
  2109.  
  2110. IceCream.ClaimParts.ToppingsPicker.ProximityPrompt.Triggered:Connect(function(player)
  2111.     IceCreamJob:FireEvent("StartJob", player, "Toppings Picker")
  2112.  
  2113.     local workers = IceCreamJob:GetRoleTotalWorkers("Toppings Picker")
  2114.     local maxWorkers = IceCreamJob:GetRoleMaxWorkers("Toppings Picker")
  2115.     IceCream.ClaimParts.ToppingsPicker.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
  2116.     IceCreamJob:FireRoleAction("Toppings Picker", "Toppings Picker Action", player, IceCreamJob:GetRoleTotalWorkers("Toppings Picker"))
  2117. end)
  2118.  
  2119. ---------------------------------------------------------------
  2120. -- ClickDetector Events
  2121. ---------------------------------------------------------------
  2122.  
  2123. for i, v in pairs(HallaPizza.ClickDetectors.Pizza:GetChildren()) do
  2124.     if v:IsA("BasePart") then
  2125.         local clickDetector: ClickDetector = v:FindFirstChild("ClickDetector")
  2126.  
  2127.         if clickDetector then
  2128.             clickDetector.MouseClick:Connect(function(player)
  2129.                 if HallaPizzaJob:IsRoleWorker("Pizza Runner", player) then
  2130.                     local tool = game.ReplicatedStorage.Tools.HallaPizza.Pizza:FindFirstChild(v.Name)
  2131.                     local anim = game.ReplicatedStorage.Animations.HallaPizza.HoldPizza
  2132.  
  2133.                     if tool and anim then
  2134.                         tool = tool:Clone()
  2135.                         tool.Parent = player.Character
  2136.  
  2137.                         tool.Handle.CFrame *= CFrame.new(0, 0, 2)
  2138.  
  2139.                         local Weld = Instance.new("Weld", tool.Handle)
  2140.                         Weld.Part0 = tool.Handle
  2141.                         Weld.Part1 = player.Character.RightHand
  2142.                         Weld.C0 = tool.Handle.CFrame:Inverse() * player.Character.RightHand.CFrame * CFrame.Angles(math.rad(180), 0, 0)
  2143.  
  2144.                         Animations[player]["Holding Pizza"] = player.Character.Humanoid.Animator:LoadAnimation(anim)
  2145.                         Animations[player]["Holding Pizza"]:Play()
  2146.                     end
  2147.                 end
  2148.             end)
  2149.         end
  2150.     end
  2151. end
  2152.  
  2153. for i, v in pairs(Restaurant.ClickDetectors.Meals:GetChildren()) do
  2154.     if v:IsA("BasePart") then
  2155.         local clickDetector: ClickDetector = v:FindFirstChild("ClickDetector")
  2156.  
  2157.         if clickDetector then
  2158.             clickDetector.MouseClick:Connect(function(player)
  2159.                 if RestaurantJob:IsRoleWorker("Delivery", player) then
  2160.                     local tool = game.ReplicatedStorage.Tools.Restaurant.Meals:FindFirstChild(v.Name)
  2161.                     print(v.Name)
  2162.                     print(tool)
  2163.                     local anim = game.ReplicatedStorage.Animations.Restaurant.HoldMeal
  2164.  
  2165.                     if tool and anim then
  2166.                         tool = tool:Clone()
  2167.                         tool.Parent = player.Character
  2168.                         tool.Handle.CFrame *= CFrame.new(0, 0, 2)
  2169.  
  2170.                         local Weld = Instance.new("Weld", tool.Handle)
  2171.                         Weld.Part0 = tool.Handle
  2172.                         Weld.Part1 = player.Character.RightHand
  2173.                         Weld.C0 = tool.Handle.CFrame:Inverse() * player.Character.RightHand.CFrame * CFrame.Angles(math.rad(30), 0, 0) * CFrame.new(0, 0.5, 1)
  2174.  
  2175.                         Animations[player]["Holding Plate"] = player.Character.Humanoid.Animator:LoadAnimation(anim)
  2176.                         Animations[player]["Holding Plate"]:Play()
  2177.                     end
  2178.                 end
  2179.             end)
  2180.         end
  2181.     end
  2182. end
  2183.  
  2184. JobRemotes.QuitJob.OnServerEvent:Connect(function(player)
  2185.     if HallaPizzaJob:IsWorker(player) then
  2186.         HallaPizzaJob:FireEvent("QuitJob", player)
  2187.     end
  2188.     if RestaurantJob:IsWorker(player) then
  2189.         RestaurantJob:FireEvent("QuitJob", player)
  2190.     end
  2191.     if IceCreamJob:IsWorker(player) then
  2192.         IceCreamJob:FireEvent("QuitJob", player)
  2193.     end
  2194. end)
  2195.  
  2196. game["Run Service"].Heartbeat:Connect(function()
  2197.     game["Run Service"].Heartbeat:Wait()
  2198.     for i, v in pairs(game.Players:GetChildren()) do
  2199.         local player = v
  2200.         local Pay = 0
  2201.         local IsWorker = false
  2202.         if HallaPizzaJob:IsWorker(player) then
  2203.             Pay = HallaPizzaJob:GetPlayerPay(player)
  2204.             IsWorker = true
  2205.         end
  2206.         if RestaurantJob:IsWorker(player) then
  2207.             Pay = RestaurantJob:GetPlayerPay(player)
  2208.             IsWorker = true
  2209.         end
  2210.         if IceCreamJob:IsWorker(player) then
  2211.             Pay = IceCreamJob:GetPlayerPay(player)
  2212.             IsWorker = true
  2213.         end
  2214.  
  2215.         if IsWorker then
  2216.             JobRemotes.ShowStats:FireClient(player, Pay)
  2217.         end
  2218.     end
  2219. end)
  2220.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement