Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ChatService = game:GetService("Chat")
- local PhysicsService = game:GetService("PhysicsService")
- local TweenService = game:GetService("TweenService")
- local Remotes = game.ReplicatedStorage.Remotes
- local JobRemotes = Remotes.JobRemotes
- local HallaPizza = workspace.JobSystem.HallaPizza
- local Restaurant = workspace.JobSystem.Restaurant
- local IceCream = workspace.JobSystem["Ice Cream"]
- local JobModule = require(script.Parent.Modules.Job)
- local ListOfJobs = require(script.Parent.Modules.ListOfJobs)
- local ListOfCustomerMsgs = require(script.Parent.Modules.ListOfCustomerMsgs)
- local Orders = require(script.Parent.Modules.Orders)
- -- Values
- local PlayerConnections = {} -- Every Connection that we add along the way
- local Animations = {} -- Animations that the player is currently playing
- local RoleStocks = {} -- Stocks for a player's sepcific role
- -- Jobs
- local HallaPizzaJob = JobModule.new("HallaPizza", ListOfJobs.HallaPizza.Roles, ListOfJobs.HallaPizza.MaxWorkers)
- local RestaurantJob = JobModule.new("Restaurant", ListOfJobs.Restaurant.Roles, ListOfJobs.Restaurant.MaxWorkers)
- local IceCreamJob = JobModule.new("Ice Cream", ListOfJobs["Ice Cream"].Roles, ListOfJobs["Ice Cream"].MaxWorkers)
- task.wait()
- PhysicsService:RegisterCollisionGroup("Customers")
- PhysicsService:CollisionGroupSetCollidable("Customers", "Players", false)
- game.Players.PlayerAdded:Connect(function(player)
- -- Set the player values
- PlayerConnections[player] = {}
- Animations[player] = {}
- RoleStocks[player] = 0
- -- Goes through and activates each click detector
- for i, v in pairs(workspace.JobSystem:GetDescendants()) do
- if v:IsA("ClickDetector") then
- JobRemotes.ActivateClickDetector:FireClient(player, v, false)
- end
- end
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- -- Removes Worker from metatables
- HallaPizzaJob.RemoveWorker(player)
- RestaurantJob.RemoveWorker(player)
- IceCreamJob.RemoveWorker(player)
- -- Disconnect all RBX Events
- for i, v in pairs(PlayerConnections[player]) do
- v:Disconnect()
- end
- PlayerConnections[player] = nil
- Animations[player] = nil
- RoleStocks[player] = nil
- -- Destroy all Player Customers owned by this player
- for i, v in pairs(workspace.JobSystem.PlayerCustomers:GetChildren()) do
- if v:FindFirstChild("Host") then
- if v:FindFirstChild("Host").Value == player then
- v:Destroy()
- end
- end
- end
- end)
- local function changeModelTranparency(Model: Model, Transparency: number)
- for _, v: Part in pairs(Model:GetDescendants()) do
- if v:IsA("BasePart") then
- v.Transparency = Transparency
- end
- end
- end
- local function changeTransparency(model: Model, transparency: number, name)
- for _, v in pairs(model:GetDescendants()) do
- if v.Name == name then
- if v:IsA("BasePart") then
- v.Transparency = transparency
- elseif v:IsA("Model") then
- changeModelTranparency(v, transparency)
- end
- end
- end
- end
- --Import the module so you can start using it
- local SimplePath = require(script.SimplePath)
- function CreatePath(Dummy: Model, Goal)
- --Create a new Path using the Dummy
- local Path = SimplePath.new(Dummy)
- --Helps to visualize the path
- Path.Visualize = false
- --Dummy knows to compute path again if something blocks the path
- Path.Blocked:Connect(function()
- Path:Run(Goal)
- end)
- --If the position of Goal changes at the next waypoint, compute path again
- Path.WaypointReached:Connect(function()
- Path:Run(Goal)
- end)
- Path:Run(Goal)
- end
- -- Parameters Player, RoleName
- function StartJob(...)
- local pack = table.pack(...)
- local JobName = pack[1]
- local EventName = pack[2]
- local plr = pack[3]
- local role = pack[4]
- local promptTriggeredBy: ProximityPrompt = pack[5]
- if HasJob(plr) then return end
- local success = false
- local pay = 0
- if JobName == HallaPizzaJob.JobName then
- success = HallaPizzaJob.AddWorker(plr, role)
- pay = HallaPizzaJob:GetPlayerPay(plr)
- elseif JobName == RestaurantJob.JobName then
- success = RestaurantJob.AddWorker(plr, role)
- pay = RestaurantJob:GetPlayerPay(plr)
- elseif JobName == IceCreamJob.JobName then
- success = IceCreamJob.AddWorker(plr, role)
- pay = IceCreamJob:GetPlayerPay(plr)
- end
- if success then
- for i, v:ProximityPrompt in pairs(workspace.JobSystem[JobName].ClaimParts:GetDescendants()) do
- if v:IsA("ProximityPrompt") then
- JobRemotes.ActivatePrompt:FireClient(plr, v, false)
- elseif v:IsA("ClickDetector") then
- JobRemotes.ActivateClickDetector:FireClient(plr, v, true)
- end
- end
- JobRemotes.ShowFrames:FireClient(plr, true)
- JobRemotes.ShowStats:FireClient(plr, pay)
- end
- end
- function HasJob(player: Player)
- local JobStats = player:FindFirstChild("JobStats")
- if JobStats then
- local HasJob = JobStats:FindFirstChild("HasJob")
- if HasJob then
- return HasJob.Value
- end
- end
- end
- --function ChangeRole(...)
- -- local pack = table.pack(...)
- -- local JobName = pack[1]
- -- local EventName = pack[2]
- -- local plr = pack[3]
- -- local role = pack[4]
- -- if not HasJob(plr) then return end
- -- if JobName == HallaPizzaJob.JobName then
- -- HallaPizzaJob.ChangePlayerRole(plr, role)
- -- elseif JobName == RestaurantJob.JobName then
- -- RestaurantJob.ChangePlayerRole(plr, role)
- -- elseif JobName == IceCreamJob.JobName then
- -- IceCreamJob.ChangePlayerRole(plr, role)
- -- end
- --end
- -- For every building, the interaction with the cashier and customer
- function CashierCustomerAction(...)
- local pack = table.pack(...)
- local JobName = pack[1]
- local ActionName = pack[2]
- local plr = pack[3]
- local role = pack[4]
- if not HasJob(plr) then return end
- local Customers = game.ReplicatedStorage.Customers:GetChildren()
- local Customer = Customers[math.random(1, #Customers)]:Clone()
- Customer.Parent = workspace.JobSystem.PlayerCustomers
- Customer.HumanoidRootPart:SetNetworkOwner(plr)
- local Host = Instance.new("ObjectValue", Customer)
- Host.Name = "Host"
- Host.Value = plr
- for i, v: BasePart in pairs(Customer:GetDescendants()) do
- if v:IsA("BasePart") then
- v.CollisionGroup = "Customers"
- end
- end
- local Humanoid: Humanoid = Customer:WaitForChild("Humanoid")
- local Register
- local Waypoints
- if JobName == HallaPizzaJob.JobName then
- local Registers = HallaPizza.Registers
- if Registers.Register1.Owner.Value == plr then
- Register = Registers.Register1
- elseif Registers.Register2.Owner.Value == plr then
- Register = Registers.Register2
- end
- if Register then
- Waypoints = HallaPizza.Waypoints:FindFirstChild(Register.Name)
- else
- return
- end
- elseif JobName == RestaurantJob.JobName then
- local Registers = Restaurant.Registers
- if Registers.Register1.Owner.Value == plr then
- Register = Registers.Register1
- elseif Registers.Register2.Owner.Value == plr then
- Register = Registers.Register2
- end
- if Register then
- Waypoints = Restaurant.Waypoints:FindFirstChild(Register.Name)
- else
- return
- end
- elseif JobName == IceCreamJob.JobName then
- local Registers = IceCream.Registers
- if Registers.Register1.Owner.Value == plr then
- Register = Registers.Register1
- elseif Registers.Register2.Owner.Value == plr then
- Register = Registers.Register2
- end
- if Register then
- Waypoints = IceCream.Waypoints:FindFirstChild(Register.Name)
- else
- return
- end
- end
- Customer.HumanoidRootPart.CFrame = Waypoints:FindFirstChild("1").CFrame * CFrame.new(0, 2, 0)
- --CreatePath(Customer, Waypoints:FindFirstChild("5"))
- if Waypoints:FindFirstChild('3') then
- Humanoid:MoveTo(Waypoints['3'].Position)
- Humanoid.MoveToFinished:Wait()
- end
- Humanoid:MoveTo(Waypoints['5'].Position)
- task.wait(1)
- local prefix = ListOfCustomerMsgs.Prefix[math.random(1, #ListOfCustomerMsgs.Prefix)]
- local suffix = ListOfCustomerMsgs.Suffix[JobName][math.random(1, #ListOfCustomerMsgs.Suffix[JobName])]
- local msg = prefix .. suffix.Message
- ChatService:Chat(Customer:WaitForChild("Head"), msg, Enum.ChatColor.White)
- local CashierGui
- -- Sets the CashierGui to One or Two
- if JobName == HallaPizzaJob.JobName or JobName == RestaurantJob.JobName then
- CashierGui = plr.PlayerGui.CashierGui
- elseif JobName == IceCreamJob.JobName then
- CashierGui = plr.PlayerGui.CashierGui2
- end
- CashierGui.Adornee = Register.CashRegister.Value["Screen"]
- for i = 1, #CashierGui:GetChildren() do
- local clickConnection
- local function btnClick()
- print('Clicked')
- if i == suffix.Order then
- if JobName == HallaPizzaJob.JobName then
- HallaPizzaJob:Pay(plr)
- ChatService:Chat(Customer.Head, "Thanks for the Pizza 🍕!!", Enum.ChatColor.White)
- elseif JobName == RestaurantJob.JobName then
- RestaurantJob:Pay(plr)
- ChatService:Chat(Customer.Head, "Thanks for the food 🍽️!!", Enum.ChatColor.White)
- elseif JobName == IceCreamJob.JobName then
- IceCreamJob:Pay(plr)
- ChatService:Chat(Customer.Head, "Thanks for the Ice Cream 🍦!!", Enum.ChatColor.White)
- end
- else
- ChatService:Chat(Customer.Head, "Ugh, you got my order wrong!!", Enum.ChatColor.White)
- end
- for i, v in pairs(PlayerConnections[plr]) do
- v:Disconnect()
- end
- task.wait(1)
- -- Creates the path to leave the building
- if Waypoints:FindFirstChild("3") then
- --CreatePath(Customer, Waypoints:FindFirstChild("3").Position)
- Humanoid:MoveTo(Waypoints['3'].Position)
- Humanoid.MoveToFinished:Wait()
- end
- CreatePath(Customer, Waypoints:FindFirstChild("1").Position)
- task.wait(5)
- Customer:Destroy()
- CashierCustomerAction(table.unpack(pack))
- end
- clickConnection = CashierGui:FindFirstChild(i).Btn.MouseButton1Click:Connect(btnClick)
- table.insert(PlayerConnections[plr], clickConnection)
- end
- end
- -- The Delivery, Pizza Runners.
- function CustomerAction2(...)
- local pack = table.pack(...)
- local JobName = pack[1]
- local ActionName = pack[2]
- local plr = pack[3]
- local role = pack[4]
- if not HasJob(plr) then return end
- local Register
- local Waypoints
- if JobName == HallaPizzaJob.JobName then
- Waypoints = HallaPizza.Waypoints.Seats
- elseif JobName == RestaurantJob.JobName then
- Waypoints = Restaurant.Waypoints.Seats
- elseif JobName == IceCreamJob.JobName then
- Waypoints = IceCream.Waypoints.Seats
- end
- local Max = #Waypoints:GetChildren() - 2
- local num = math.random(3, Max)
- local seat: Seat = Waypoints:FindFirstChild(num)
- if seat.Occupant == nil then
- local maxAttempts = 24
- local attempts = 0
- repeat
- num = math.random(3, Max)
- seat = Waypoints:FindFirstChild(num)
- attempts += 1
- until seat.Occupant == nil and attempts ~= maxAttempts
- end
- local Customer: Model = game.ReplicatedStorage.Customers:GetChildren()
- Customer = Customer[math.random(1, #Customer)]:Clone()
- Customer.Parent = workspace.JobSystem.PlayerCustomers
- for i, v: BasePart in pairs(Customer:GetDescendants()) do
- if v:IsA("BasePart") then
- v.CollisionGroup = "Customers"
- end
- end
- local Host = Instance.new("ObjectValue", Customer)
- Host.Name = "Host"
- Host.Value = plr
- local Humanoid: Humanoid = Customer:WaitForChild("Humanoid")
- Customer.HumanoidRootPart.CFrame = Waypoints:FindFirstChild(math.random(1,2)).CFrame * CFrame.new(0, 2, 0)
- CreatePath(Customer, (seat.CFrame * CFrame.new(-4, 0, 0)).Position)
- task.wait(4)
- seat:Sit(Humanoid)
- local suffix = ListOfCustomerMsgs.Suffix[JobName][math.random(1, #ListOfCustomerMsgs.Suffix[JobName])]
- local CustomerTag = script.CustomerTag:Clone()
- local Head = Customer:WaitForChild("Head")
- if Head then
- CustomerTag.Parent = Head
- end
- CustomerTag.Frame.Icon.Image = suffix.Icon
- local ClickDetector = Instance.new("ClickDetector", Customer)
- local location
- if JobName == HallaPizzaJob.JobName then
- location = HallaPizza.ClickDetectors.Pizza
- elseif JobName == RestaurantJob.JobName then
- location = Restaurant.ClickDetectors.Meals
- end
- for i, v in pairs(location:GetDescendants()) do
- if v:IsA("ClickDetector") then
- JobRemotes.ActivateClickDetector:FireClient(plr, v, true)
- end
- end
- local connection
- connection = ClickDetector.MouseClick:Connect(function(player)
- if JobName == HallaPizzaJob.JobName then
- if HallaPizzaJob:IsRoleWorker("Pizza Runner", player) then
- local tool = player.Character:FindFirstChildWhichIsA("Folder")
- if tool then
- CustomerTag:Destroy()
- tool:Destroy()
- if Animations[player]["Holding Pizza"] then
- Animations[player]["Holding Pizza"]:Stop()
- Animations[player]["Holding Pizza"] = nil
- end
- if tool.Name == suffix.Name then
- HallaPizzaJob:Pay(plr)
- ChatService:Chat(Customer.Head, "Thanks for the Pizza 🍕!!", Enum.ChatColor.White)
- coroutine.wrap(function()
- CustomerAction2(table.unpack(pack))
- end)()
- task.wait(1) -- Time between Meal and Leaving
- if seat:FindFirstChildWhichIsA("Weld") then
- seat:FindFirstChildWhichIsA("Weld"):Destroy()
- end
- Customer:Destroy()
- else
- ChatService:Chat(Customer.Head, "Ugh, you got my order wrong!!", Enum.ChatColor.White)
- coroutine.wrap(function()
- CustomerAction2(table.unpack(pack))
- end)()
- task.wait(2) -- Time between Order and Leaving
- if seat:FindFirstChildWhichIsA("Weld") then
- seat:FindFirstChildWhichIsA("Weld"):Destroy()
- end
- Customer:Destroy()
- end
- end
- connection:Disconnect()
- end
- elseif JobName == RestaurantJob.JobName then
- local tool = player.Character:FindFirstChildWhichIsA("Folder")
- if tool then
- CustomerTag:Destroy()
- tool:Destroy()
- end
- if RestaurantJob:IsRoleWorker("Delivery", player) then
- local tool = player.Character:FindFirstChildWhichIsA("Folder")
- if tool then
- CustomerTag:Destroy()
- tool:Destroy()
- if Animations[player]["Holding Plate"] then
- Animations[player]["Holding Plate"]:Stop()
- Animations[player]["Holding Plate"] = nil
- end
- if tool.Name == suffix.Name then
- RestaurantJob:Pay(plr)
- ChatService:Chat(Customer.Head, "Thanks for the Meal 🍽️!!", Enum.ChatColor.White)
- coroutine.wrap(function()
- CustomerAction2(table.unpack(pack))
- end)()
- task.wait(2) -- Time between Meal and Leaving
- if seat:FindFirstChildWhichIsA("Weld") then
- seat:FindFirstChildWhichIsA("Weld"):Destroy()
- end
- Customer:Destroy()
- else
- ChatService:Chat(Customer.Head, "Ugh, you got my order wrong!!", Enum.ChatColor.White)
- coroutine.wrap(function()
- CustomerAction2(table.unpack(pack))
- end)()
- task.wait(2) -- Time between Order and Leaving
- if seat:FindFirstChildWhichIsA("Weld") then
- seat:FindFirstChildWhichIsA("Weld"):Destroy()
- end
- Customer:Destroy()
- end
- end
- connection:Disconnect()
- end
- end
- end)
- end
- local maxRolls = 6
- function DoughMakerAction(...)
- local pack = table.pack(...)
- local JobName = pack[1]
- local EventName = pack[2]
- local plr = pack[3]
- local station = pack[4]
- if not HasJob(plr) then return end
- -- Process, Step 1: Click the Board, Step 2: Click the Dough, Step 3: Click the Roller
- local clicks = {
- first = false,
- second = false,
- third = false,
- }
- local dly = 0.5
- local Table: Part = HallaPizza.ObjectValues.DoughMaker["Table" .. station].Value
- local Board: Part = HallaPizza.ObjectValues.DoughMaker["Board" .. station].Value
- local Dough: Part = HallaPizza.ObjectValues.DoughMaker["Dough" .. station].Value
- local Roller: Model = HallaPizza.ObjectValues.DoughMaker["Roller" .. station].Value
- local BoardItem = HallaPizza.DoughMakerItems["Board" .. station]
- local DoughItem = HallaPizza.DoughMakerItems["Dough" .. station]
- local RollerItem = HallaPizza.DoughMakerItems["Roller" .. station]
- local needToRestock = false -- whether it needs to restock or not
- -- Show the Arrow on top of the board
- JobRemotes.ShowArrow:FireClient(plr, Board)
- local Table = HallaPizza.ClickDetectors.DoughMaker["Table" .. station]
- local StandCFrame = Table.CFrame * CFrame.new(0,0,3)
- JobRemotes.ActivateClickDetector:FireClient(plr, Table.ClickDetector, false)
- local Box = HallaPizza.ClickDetectors.DoughMaker["Box"]
- local restockConnection
- if RoleStocks[plr] == maxRolls then
- needToRestock = true
- plr.Character.Humanoid.WalkSpeed = game.StarterPlayer.CharacterWalkSpeed
- plr.Character.Humanoid.JumpPower = game.StarterPlayer.CharacterJumpPower
- JobRemotes.ActivateClickDetector:FireClient(plr, Box.ClickDetector, true)
- -- Box Interaction
- restockConnection = Box.ClickDetector.MouseClick:Connect(function(player)
- if player ~= plr then return end
- JobRemotes.ShowArrow:FireClient(plr, Table)
- Table.ClickDetector.MaxActivationDistance = 32
- local anim = game.ReplicatedStorage.Animations.HoldBox
- Animations[plr]["Holding Box"] = player.Character.Humanoid.Animator:LoadAnimation(anim)
- Animations[plr]["Holding Box"]:Play()
- local boxDist = 1
- local Box = game.ReplicatedStorage.Tools.HallaPizza.Box:Clone()
- Box.Parent = player.Character
- Box.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, boxDist)
- local Weld = Instance.new("Weld", Box)
- Weld.Part0 = Box
- Weld.Part1 = player.Character.HumanoidRootPart
- Weld.C0 = Box.CFrame:Inverse() * player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, boxDist)
- local TableConnection
- TableConnection = Table.ClickDetector.MouseClick:Connect(function(player)
- if player ~= plr then return end
- -- Reset ClickDetector back to default
- Table.ClickDetector.MaxActivationDistance = 0
- Box:Destroy()
- Weld:Destroy()
- player.Character.Humanoid.WalkSpeed = 0
- player.Character.Humanoid.JumpPower = 0
- player.Character.HumanoidRootPart.CFrame = StandCFrame
- Animations[plr]["Holding Box"]:Stop()
- -- Reset rolls and set needToRestock to false
- RoleStocks[player] = 0
- needToRestock = false
- JobRemotes.ShowArrow:FireClient(plr, Board)
- end)
- table.insert(PlayerConnections[player], TableConnection)
- end)
- -- Show the Arrow on top of the board
- JobRemotes.ShowArrow:FireClient(plr, Box)
- else
- plr.Character.Humanoid.WalkSpeed = 0
- plr.Character.Humanoid.JumpPower = 0
- plr.Character.HumanoidRootPart.CFrame = StandCFrame
- end
- JobRemotes.ActivateClickDetector:FireClient(plr, HallaPizza.ClickDetectors.DoughMaker["Board"..station].ClickDetector, true)
- JobRemotes.ActivateClickDetector:FireClient(plr, HallaPizza.ClickDetectors.DoughMaker["Dough"..station].ClickDetector, true)
- JobRemotes.ActivateClickDetector:FireClient(plr, HallaPizza.ClickDetectors.DoughMaker["Roller"..station].ClickDetector, true)
- local connection
- connection = HallaPizza.ClickDetectors.DoughMaker["Board" .. station].ClickDetector.MouseClick:Connect(function(player: Player)
- if player ~= plr then return end
- if needToRestock then return end
- task.wait(dly)
- BoardItem.Transparency = 0
- JobRemotes.ShowArrow:FireClient(plr, Dough)
- clicks.first = true
- connection:Disconnect()
- end)
- local connection2
- connection2 = HallaPizza.ClickDetectors.DoughMaker["Dough" .. station].ClickDetector.MouseClick:Connect(function(player)
- if player ~= plr then return end
- if not clicks.first then return end
- if needToRestock then return end
- task.wait(dly)
- DoughItem.Transparency = 0
- JobRemotes.ShowArrow:FireClient(plr, Roller)
- clicks.second = true
- connection2:Disconnect()
- end)
- local connection3
- connection3 = HallaPizza.ClickDetectors.DoughMaker["Roller" .. station].ClickDetector.MouseClick:Connect(function(player)
- if player ~= plr then return end
- if not clicks.first or not clicks.second then return end
- if needToRestock then return end
- task.wait(dly)
- for i, v in pairs(RollerItem:GetChildren()) do
- if v:IsA("BasePart") then
- v.Transparency = 0
- end
- end
- clicks.third = true
- HallaPizzaJob:Pay(plr)
- connection3:Disconnect()
- RoleStocks[plr] += 1
- local duration = 0.5
- local travelDist = 3
- local initialCFrame = RollerItem.PrimaryPart.CFrame
- local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 3, true)
- local tween = TweenService:Create(RollerItem.PrimaryPart, tweenInfo, {
- CFrame = (RollerItem.PrimaryPart.CFrame * CFrame.new(0, 0, -travelDist))
- })
- local anim = game.ReplicatedStorage.Animations.HallaPizza.RollingAnimation
- Animations[player]["Rolling Animation"] = player.Character.Humanoid.Animator:LoadAnimation(anim)
- Animations[player]["Rolling Animation"]:Play()
- tween:Play()
- tween.Completed:Wait()
- Animations[player]["Rolling Animation"]:Stop()
- Animations[player]["Rolling Animation"] = nil
- -- Reset back to initial transparency
- for i, v in pairs(RollerItem:GetChildren()) do
- if v:IsA("BasePart") then
- v.Transparency = 1
- end
- end
- BoardItem.Transparency = 1
- DoughItem.Transparency = 1
- RollerItem.PrimaryPart.CFrame = initialCFrame
- plr.Character.Humanoid.WalkSpeed = game.StarterPlayer.CharacterWalkSpeed
- plr.Character.Humanoid.JumpPower = game.StarterPlayer.CharacterJumpPower
- DoughMakerAction(table.unpack(pack))
- end)
- table.insert(PlayerConnections[plr], connection) -- insert connection so we can disconnect later
- table.insert(PlayerConnections[plr], connection2) -- insert connection so we can disconnect later
- table.insert(PlayerConnections[plr], connection3) -- insert connection so we can disconnect later
- table.insert(PlayerConnections[plr], restockConnection) -- insert connection so we can disconnect later
- end
- local maxPizza = 8
- function PizzaMakerAction(...)
- local pack = table.pack(...)
- local JobName = pack[1]
- local EventName = pack[2]
- local plr = pack[3]
- local station = pack[4]
- if not HasJob(plr) then return end
- local pizza = Orders.Clone(Orders.HallaPizza.Order[math.random(1, #Orders.HallaPizza.Order)])
- local PizzaModel = HallaPizza.PizzaMakerItems["Pizza" .. station]
- local PM = HallaPizza.ObjectValues.PizzaMaker
- local PMC = HallaPizza.ClickDetectors.PizzaMaker
- local Screen = PM["Screen" .. station].Value
- local inStock = true
- local Table = HallaPizza.ClickDetectors.PizzaMaker["Table"..station]
- JobRemotes.ActivateClickDetector:FireClient(plr, Table.ClickDetector, false)
- JobRemotes.ActivateClickDetector:FireClient(plr, HallaPizza.ClickDetectors.PizzaMaker["Box"].ClickDetector, false)
- if RoleStocks[plr] == maxPizza then
- Screen.GUI.Icon.Image = "http://www.roblox.com/asset/?id=12232016774" -- Restock Icon
- inStock = false
- JobRemotes.ShowArrow:FireClient(plr, HallaPizza.ClickDetectors.PizzaMaker["Box"])
- JobRemotes.ActivateClickDetector:FireClient(plr, HallaPizza.ClickDetectors.PizzaMaker["Box"].ClickDetector, true)
- local connection
- connection = HallaPizza.ClickDetectors.PizzaMaker["Box"].ClickDetector.MouseClick:Connect(function(player)
- if player ~= plr then return end
- local anim = game.ReplicatedStorage.Animations.HoldBox
- Animations[plr]["Holding Box"] = player.Character.Humanoid.Animator:LoadAnimation(anim)
- Animations[plr]["Holding Box"]:Play()
- local boxDist = 1
- local Box = game.ReplicatedStorage.Tools.HallaPizza.Box:Clone()
- Box.Parent = player.Character
- Box.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, boxDist)
- local Weld = Instance.new("Weld", Box)
- Weld.Part0 = Box
- Weld.Part1 = player.Character.HumanoidRootPart
- Weld.C0 = Box.CFrame:Inverse() * player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, boxDist)
- JobRemotes.ActivateClickDetector:FireClient(plr, Table.ClickDetector, true)
- JobRemotes.ShowArrow:FireClient(plr, Table)
- connection:Disconnect()
- end)
- local connection2
- connection2 = Table.ClickDetector.MouseClick:Connect(function(player)
- if player ~= plr then return end
- task.wait(0.5)
- inStock = true
- JobRemotes.ActivateClickDetector:FireClient(plr, HallaPizza.ClickDetectors.PizzaMaker["Table"..station].ClickDetector, false)
- if plr.Character:FindFirstChild("Box") then
- plr.Character:FindFirstChild("Box"):Destroy()
- Animations[plr]["Holding Box"]:Stop()
- Animations[plr]["Holding Box"] = nil
- end
- player.Character.Humanoid.WalkSpeed = 0
- player.Character.Humanoid.JumpPower = 0
- player.Character.HumanoidRootPart.CFrame = Table.CFrame * CFrame.new(0,0,3)
- RoleStocks[plr] = 0
- connection2:Disconnect()
- end)
- table.insert(PlayerConnections[plr], connection)
- table.insert(PlayerConnections[plr], connection2)
- repeat task.wait()
- if connection2 == nil then
- break
- end
- until inStock
- else
- plr.Character.Humanoid.WalkSpeed = 0
- plr.Character.Humanoid.JumpPower = 0
- plr.Character.HumanoidRootPart.CFrame = Table.CFrame * CFrame.new(0,0,3)
- end
- Screen.GUI.Icon.Image = pizza.Icon
- local clicks = pizza.Clicks
- local isRunning = true
- local isOnNumber = 1
- for i = 1, #Orders.HallaPizza.ClickDetectors do
- local CDNAME = Orders.HallaPizza.ClickDetectors[i]
- local isInRecipe = false
- for _, k in pairs(clicks) do
- if k.Name == CDNAME then
- isInRecipe = true
- end
- end
- if not isInRecipe then
- local connection
- JobRemotes.ActivateClickDetector:FireClient(plr, PMC[CDNAME .. station].ClickDetector, true)
- connection = PMC[CDNAME .. station].ClickDetector.MouseClick:Connect(function(player)
- if player ~= plr then return end
- isRunning = false
- changeModelTranparency(PizzaModel, 1)
- for i, v in pairs(PlayerConnections[plr]) do
- v:Disconnect()
- end
- plr.Character.Humanoid.WalkSpeed = game.StarterPlayer.CharacterWalkSpeed
- plr.Character.Humanoid.JumpPower = game.StarterPlayer.CharacterJumpPower
- RoleStocks[plr] += 1
- PizzaMakerAction(table.unpack(pack))
- end)
- table.insert(PlayerConnections[plr], connection)
- end
- end
- for i = 1, #clicks do
- local click = clicks[i]
- local name = click.Name .. station
- if i == 1 then
- JobRemotes.ShowArrow:FireClient(plr, PMC[name])
- end
- local connection
- JobRemotes.ActivateClickDetector:FireClient(plr, PMC[name].ClickDetector, true)
- connection = PMC[name].ClickDetector.MouseClick:Connect(function(player)
- if player ~= plr then return end
- if i ~= 1 then
- local clminus = clicks[i - 1] -- Current one minus 1 (to go back)
- if clminus then
- if not clminus.Done then
- isRunning = false
- changeModelTranparency(PizzaModel, 1)
- RoleStocks[plr] += 1
- PizzaMakerAction(table.unpack(pack))
- connection:Disconnect()
- return
- end
- end
- end
- task.wait(0.5)
- changeTransparency(PizzaModel, 0, click.Name)
- task.wait(0.5)
- if i == #clicks then
- for i, v in pairs(PlayerConnections[plr]) do
- v:Disconnect()
- PlayerConnections[plr][i] = nil
- end
- local clone: Model = PizzaModel:Clone()
- clone.Parent = workspace.JobSystem.Items
- local Host = Instance.new("ObjectValue", clone)
- Host.Value = plr
- if clone.PrimaryPart then
- coroutine.wrap(function()
- local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
- for i = 1, 3 do
- local waypoint: Part = HallaPizza.Waypoints.PizzaMaker[i]
- if waypoint then
- local tween = TweenService:Create(clone.PrimaryPart, tweenInfo, {
- CFrame = waypoint.CFrame * CFrame.Angles(math.rad(-90), 0, 0)
- })
- tween:Play()
- tween.Completed:Wait()
- end
- end
- clone:Destroy()
- end)()
- end
- plr.Character.Humanoid.WalkSpeed = game.StarterPlayer.CharacterWalkSpeed
- plr.Character.Humanoid.JumpPower = game.StarterPlayer.CharacterJumpPower
- isRunning = false
- changeModelTranparency(PizzaModel, 1)
- HallaPizzaJob:Pay(plr)
- RoleStocks[plr] += 1
- PizzaMakerAction(table.unpack(pack))
- end
- isOnNumber += 1
- click.Done = true
- connection:Disconnect()
- end)
- table.insert(PlayerConnections[plr], connection)
- end
- coroutine.wrap(function()
- while isRunning do
- if #PlayerConnections[plr] == 0 then
- break
- end
- if isOnNumber ~= 1 then
- JobRemotes.ShowArrow:FireClient(plr, PMC[clicks[isOnNumber].Name .. station])
- end
- task.wait()
- end
- end)()
- end
- function DishWasherAction(...)
- local pack = table.pack(...)
- local JobName = pack[1]
- local EventName = pack[2]
- local plr = pack[3]
- local station = pack[4]
- if not HasJob(plr) then return end
- local clicks = {
- first = false,
- second = false
- }
- local Dishes = Restaurant.ClickDetectors.DishWasher["Dishes" .. station]
- local Sink = Restaurant.ClickDetectors.DishWasher["Sink" .. station]
- local Plate = Restaurant.DishWasherItems["Plate"..station]
- local Water = Restaurant.DishWasherItems["Water"..station]
- local Table = Restaurant.DishWasherItems["Table"..station]
- JobRemotes.ShowArrow:FireClient(plr, Dishes)
- JobRemotes.ActivateClickDetector:FireClient(plr, Dishes.ClickDetector, true)
- JobRemotes.ActivateClickDetector:FireClient(plr, Sink.ClickDetector, true)
- plr.Character.Humanoid.WalkSpeed = 0
- plr.Character.Humanoid.JumpPower = 0
- plr.Character.HumanoidRootPart.CFrame = Table.CFrame * CFrame.new(-3,0, 0) * CFrame.Angles(0, -math.rad(90), 0)
- local connection
- connection = Dishes.ClickDetector.MouseClick:Connect(function(player)
- if player ~= plr then return end
- Plate.Transparency = 0
- JobRemotes.ShowArrow:FireClient(plr, Sink)
- clicks.first = true
- connection:Disconnect()
- end)
- local connection2
- connection2 = Sink.ClickDetector.MouseClick:Connect(function(player: Player)
- if player ~= plr then return end
- if not clicks.first then return end
- Water.ParticleEmitter.Enabled = true
- local anim = game.ReplicatedStorage.Animations.Restaurant.Cleaning
- Animations[plr]["Cleaning"] = player.Character.Humanoid.Animator:LoadAnimation(anim)
- Animations[plr]["Cleaning"]:Play()
- task.wait(3)
- Plate.Transparency = 1
- Water.ParticleEmitter.Enabled = false
- Animations[plr]["Cleaning"]:Stop()
- Animations[plr]["Cleaning"] = nil
- connection2:Disconnect()
- RestaurantJob:Pay(plr)
- DishWasherAction(table.unpack(pack))
- clicks.second = true
- end)
- table.insert(PlayerConnections[plr], connection)
- table.insert(PlayerConnections[plr], connection2)
- end
- local MaxStocks = 7
- function CookerAction(...)
- local pack = table.pack(...)
- local JobName = pack[1]
- local EventName = pack[2]
- local plr = pack[3]
- local station = pack[4]
- if not HasJob(plr) then return end
- local inStock = true
- if RoleStocks[plr] == MaxStocks then
- inStock = false
- JobRemotes.ShowArrow:FireClient(plr, Restaurant.ClickDetectors.Cooker.Box)
- JobRemotes.ActivateClickDetector:FireClient(plr, Restaurant.ClickDetectors.Cooker.Box.ClickDetector, true)
- local connection
- connection = Restaurant.ClickDetectors.Cooker.Box.ClickDetector.MouseClick:Connect(function(player)
- if player ~= player then return end
- local boxDist = 1
- local Box = game.ReplicatedStorage.Tools.Restaurant.Box:Clone()
- Box.Parent = player.Character
- Box.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, boxDist)
- local Weld = Instance.new("Weld", Box)
- Weld.Part0 = Box
- Weld.Part1 = player.Character.HumanoidRootPart
- Weld.C0 = Box.CFrame:Inverse() * player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, boxDist)
- local anim = game.ReplicatedStorage.Animations.HoldBox
- Animations[plr]["Holding Box"] = player.Character.Humanoid.Animator:LoadAnimation(anim)
- Animations[plr]["Holding Box"]:Play()
- JobRemotes.ShowArrow:FireClient(plr, Restaurant.ClickDetectors.Cooker.Restock)
- JobRemotes.ActivateClickDetector:FireClient(plr, Restaurant.ClickDetectors.Cooker.Restock.ClickDetector, true)
- local connection2
- connection2 = Restaurant.ClickDetectors.Cooker.Restock.ClickDetector.MouseClick:Connect(function(player)
- if plr.Character:FindFirstChild("Box") then
- plr.Character:FindFirstChild("Box"):Destroy()
- Animations[plr]["Holding Box"]:Stop()
- Animations[plr]["Holding Box"] = nil
- end
- JobRemotes.ActivateClickDetector:FireClient(plr, Restaurant.ClickDetectors.Cooker.Restock.ClickDetector, false)
- inStock = true
- JobRemotes.ShowArrow:FireClient(plr)
- RoleStocks[plr] = 0
- connection2:Disconnect()
- end)
- table.insert(PlayerConnections[plr], connection2)
- connection:Disconnect()
- end)
- table.insert(PlayerConnections[plr], connection)
- repeat task.wait()
- if connection == nil then
- break
- end
- until inStock
- end
- local randomAction = math.random(1, 4)
- JobRemotes.ShowArrow:FireClient(plr, Restaurant.ClickDetectors.Cooker[randomAction])
- local connection
- JobRemotes.ActivateClickDetector:FireClient(plr, Restaurant.ClickDetectors.Cooker[randomAction].ClickDetector, true)
- connection = Restaurant.ClickDetectors.Cooker[randomAction].ClickDetector.MouseClick:Connect(function(player)
- if player ~= plr then return end
- local Pan = Restaurant.ClickDetectors.Cooker.Pan
- local Fryer = Restaurant.ClickDetectors.Cooker.Fryer
- local Stove = Restaurant.ClickDetectors.Cooker.Stove
- JobRemotes.ActivateClickDetector:FireClient(plr, Pan.ClickDetector, true)
- JobRemotes.ActivateClickDetector:FireClient(plr, Fryer.ClickDetector, true)
- JobRemotes.ActivateClickDetector:FireClient(plr, Stove.ClickDetector, true)
- if randomAction == 1 then -- Chicken
- JobRemotes.ShowArrow:FireClient(plr, Fryer)
- local connection
- connection = Fryer.ClickDetector.MouseClick:Connect(function(player)
- if player ~= plr then return end
- Fryer.Smoke.Enabled = true
- -- Disable ClickDetectors
- JobRemotes.ActivateClickDetector:FireClient(plr, Pan.ClickDetector, false)
- JobRemotes.ActivateClickDetector:FireClient(plr, Fryer.ClickDetector, false)
- JobRemotes.ActivateClickDetector:FireClient(plr, Stove.ClickDetector, false)
- task.wait(3)
- Fryer.Smoke.Enabled = false
- connection:Disconnect()
- RestaurantJob:Pay(plr)
- RoleStocks[plr] += 1
- CookerAction(table.unpack(pack))
- end)
- table.insert(PlayerConnections[plr], connection)
- elseif randomAction == 2 then -- Breakfast
- JobRemotes.ShowArrow:FireClient(plr, Pan)
- local connection
- connection = Pan.ClickDetector.MouseClick:Connect(function(player)
- if player ~= plr then return end
- Pan.Smoke.Enabled = true
- -- Disable ClickDetectors
- JobRemotes.ActivateClickDetector:FireClient(plr, Pan.ClickDetector, false)
- JobRemotes.ActivateClickDetector:FireClient(plr, Fryer.ClickDetector, false)
- JobRemotes.ActivateClickDetector:FireClient(plr, Stove.ClickDetector, false)
- task.wait(3)
- Pan.Smoke.Enabled = false
- connection:Disconnect()
- RestaurantJob:Pay(plr)
- RoleStocks[plr] += 1
- CookerAction(table.unpack(pack))
- end)
- table.insert(PlayerConnections[plr], connection)
- elseif randomAction == 3 then -- Sandwich
- JobRemotes.ShowArrow:FireClient(plr, Stove)
- local connection
- connection = Stove.ClickDetector.MouseClick:Connect(function(player)
- if player ~= plr then return end
- Stove.Smoke.Enabled = true
- -- Disable ClickDetectors
- JobRemotes.ActivateClickDetector:FireClient(plr, Pan.ClickDetector, false)
- JobRemotes.ActivateClickDetector:FireClient(plr, Fryer.ClickDetector, false)
- JobRemotes.ActivateClickDetector:FireClient(plr, Stove.ClickDetector, false)
- task.wait(3)
- Stove.Smoke.Enabled = false
- connection:Disconnect()
- RestaurantJob:Pay(plr)
- RoleStocks[plr] += 1
- CookerAction(table.unpack(pack))
- end)
- table.insert(PlayerConnections[plr], connection)
- elseif randomAction == 4 then -- Fish
- JobRemotes.ShowArrow:FireClient(plr, Pan)
- local connection
- connection = Pan.ClickDetector.MouseClick:Connect(function(player)
- if player ~= plr then return end
- Pan.Smoke.Enabled = true
- JobRemotes.ShowArrow:FireClient(plr, Fryer)
- local connection2
- connection2 = Fryer.ClickDetector.MouseClick:Connect(function(player)
- if player ~= plr then return end
- Fryer.Smoke.Enabled = true
- -- Disable ClickDetectors
- JobRemotes.ActivateClickDetector:FireClient(plr, Pan.ClickDetector, false)
- JobRemotes.ActivateClickDetector:FireClient(plr, Fryer.ClickDetector, false)
- JobRemotes.ActivateClickDetector:FireClient(plr, Stove.ClickDetector, false)
- task.wait(3)
- Fryer.Smoke.Enabled = false
- connection2:Disconnect()
- RestaurantJob:Pay(plr)
- RoleStocks[plr] += 1
- CookerAction(table.unpack(pack))
- end)
- task.wait(3)
- Pan.Smoke.Enabled = false
- connection:Disconnect()
- table.insert(PlayerConnections[plr], connection2)
- end)
- table.insert(PlayerConnections[plr], connection)
- end
- JobRemotes.ActivateClickDetector:FireClient(plr, Restaurant.ClickDetectors.Cooker[randomAction].ClickDetector, false)
- connection:Disconnect()
- end)
- table.insert(PlayerConnections[plr], connection)
- end
- local MaxRestock = 2
- function ChopperAction(...)
- local pack = table.pack(...)
- local JobName = pack[1]
- local EventName = pack[2]
- local plr: Player = pack[3]
- local station = pack[4]
- if not HasJob(plr) then return end
- local inStock = true
- if RoleStocks[plr] >= MaxRestock then
- plr.Character.Humanoid.WalkSpeed = 16
- plr.Character.Humanoid.JumpPower = 7.2
- inStock = false
- JobRemotes.ActivateClickDetector:FireClient(plr, Restaurant.Restaurant.ChoppingRestock.ClickDetector, true)
- JobRemotes.ShowArrow:FireClient(plr, Restaurant.Restaurant.ChoppingRestock)
- local connection0
- connection0 = Restaurant.Restaurant.ChoppingRestock.ClickDetector.MouseClick:Connect(function(player)
- if plr ~= player then return end
- local Box = game.ReplicatedStorage.Tools["Restaurant"].Box:Clone()
- Box.Parent = player.Character
- Box.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, 1)
- local Weld = Instance.new("Weld", Box)
- Weld.Part0 = Box
- Weld.Part1 = player.Character.HumanoidRootPart
- Weld.C0 = Box.CFrame:Inverse() * player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, 2)
- local anim = game.ReplicatedStorage.Animations.HoldBox
- Animations[plr]["Holding Box"] = player.Character.Humanoid.Animator:LoadAnimation(anim)
- Animations[plr]["Holding Box"]:Play()
- JobRemotes.ShowArrow:FireClient(plr, Restaurant.Restaurant.RestockPlace)
- JobRemotes.ActivateClickDetector:FireClient(plr, Restaurant.Restaurant.RestockPlace.ClickDetector, true)
- Restaurant.Restaurant.RestockPlace.CanQuery = true
- local connection2
- connection2 = Restaurant.Restaurant.RestockPlace.ClickDetector.MouseClick:Connect(function(player)
- if plr.Character:FindFirstChild("Box") then
- plr.Character:FindFirstChild("Box"):Destroy()
- Animations[plr]["Holding Box"]:Stop()
- Animations[plr]["Holding Box"] = nil
- end
- inStock = true
- JobRemotes.ShowArrow:FireClient(plr)
- JobRemotes.ActivateClickDetector:FireClient(plr, Restaurant.Restaurant.RestockPlace.ClickDetector, false)
- RoleStocks[plr] = 0
- connection2:Disconnect()
- end)
- table.insert(PlayerConnections[plr], connection2)
- connection0:Disconnect()
- end)
- table.insert(PlayerConnections[plr], connection0)
- repeat task.wait()
- if connection0 == nil then
- break
- end
- until inStock
- end
- Restaurant.Restaurant.RestockPlace.CanQuery = false
- plr.Character.Humanoid.WalkSpeed = 0
- plr.Character.Humanoid.JumpPower = 0
- plr.Character.HumanoidRootPart.CFrame = Restaurant.ChopperItems["Stand"..station].CFrame * CFrame.new(0,1,0)
- local Board = Restaurant.ClickDetectors.Chopper["Board"..station]
- local Knife = Restaurant.ClickDetectors.Chopper["Knife"..station]
- local BoardItem = Restaurant.ChopperItems["Board"..station]
- local KnifeItem = Restaurant.ChopperItems["Knife"..station]
- local randomNum = math.random(1, 4)
- local food
- local plate
- if randomNum == 1 then
- food = Restaurant.ChopperItems["C".. station]
- plate = Restaurant.ClickDetectors.Chopper["C".. station]
- elseif randomNum == 2 then
- food = Restaurant.ChopperItems["B".. station]
- plate = Restaurant.ClickDetectors.Chopper["B".. station]
- elseif randomNum == 3 then
- food = Restaurant.ChopperItems["H".. station]
- plate = Restaurant.ClickDetectors.Chopper["H".. station]
- elseif randomNum == 4 then
- food = Restaurant.ChopperItems["F".. station]
- plate = Restaurant.ClickDetectors.Chopper["F".. station]
- end
- if food and plate then
- JobRemotes.ShowArrow:FireClient(plr, Board)
- local connection
- local connection2
- local connection3
- -- Steps/Process
- local clicks = {
- first = false,
- second = false,
- third = false
- }
- JobRemotes.ActivateClickDetector:FireClient(plr, Board.ClickDetector, true)
- JobRemotes.ActivateClickDetector:FireClient(plr, plate.ClickDetector, true)
- JobRemotes.ActivateClickDetector:FireClient(plr, Knife.ClickDetector, true)
- connection = Board.ClickDetector.MouseClick:Connect(function(player)
- if player ~= plr then return end
- BoardItem.Transparency = 0
- JobRemotes.ShowArrow:FireClient(plr, plate)
- clicks.first = true
- connection:Disconnect()
- end)
- connection2 = plate.ClickDetector.MouseClick:Connect(function(player)
- if player ~= plr then return end
- if not clicks.first then return end
- changeModelTranparency(food, 0)
- JobRemotes.ShowArrow:FireClient(plr, Knife)
- clicks.second = true
- connection2:Disconnect()
- end)
- connection3 = Knife.ClickDetector.MouseClick:Connect(function(player)
- if player ~= plr then return end
- if not clicks.second then return end
- changeTransparency(KnifeItem, 0, "Part")
- local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 3, true)
- local tween = TweenService:Create(KnifeItem.PrimaryPart, tweenInfo, {
- CFrame = (KnifeItem.PrimaryPart.CFrame * CFrame.Angles(math.rad(10), 0, 0)) * CFrame.new(-2, 0, 0)
- })
- local anim = game.ReplicatedStorage.Animations.Restaurant.Chopping
- Animations[player]["Chopping Animation"] = player.Character.Humanoid.Animator:LoadAnimation(anim)
- Animations[player]["Chopping Animation"]:Play()
- tween:Play()
- tween.Completed:Wait()
- Animations[player]["Chopping Animation"]:Stop()
- Animations[player]["Chopping Animation"] = nil
- changeModelTranparency(KnifeItem, 1)
- changeModelTranparency(food, 1)
- BoardItem.Transparency = 1
- RestaurantJob:Pay(plr)
- RoleStocks[plr] += 1
- ChopperAction(table.unpack(pack))
- clicks.third = true
- connection3:Disconnect()
- end)
- table.insert(PlayerConnections[plr], connection)
- table.insert(PlayerConnections[plr], connection2)
- table.insert(PlayerConnections[plr], connection3)
- end
- end
- local MaxStock = 7
- function FlavorPickerAction(...)
- local pack = table.pack(...)
- local JobName = pack[1]
- local EventName = pack[2]
- local plr = pack[3]
- local station = pack[4]
- if not HasJob(plr) then return end
- local inStock = true
- JobRemotes.FlavorsTransparency:FireClient(plr, IceCream["Ice cream shop"].Flavs.Flavors:GetChildren(), RoleStocks[plr] / MaxStock)
- JobRemotes.ActivateClickDetector:FireClient(plr, IceCream.ClickDetectors.IceCreamStock.ClickDetector, false)
- if RoleStocks[plr] == MaxStock then
- inStock = false
- print("I am here")
- JobRemotes.HighlightItem:FireClient(plr, IceCream.ClickDetectors.Boxes)
- JobRemotes.ShowArrow:FireClient(plr, IceCream.ClickDetectors.Boxes)
- local connection
- JobRemotes.ActivateClickDetector:FireClient(plr, IceCream.ClickDetectors.Boxes.ClickDetector, true)
- connection = IceCream.ClickDetectors.Boxes.ClickDetector.MouseClick:Connect(function(player)
- if player ~= player then return end
- local boxDist = 1
- local Box = game.ReplicatedStorage.Tools["Ice Cream"].Box:Clone()
- Box.Parent = player.Character
- Box.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, boxDist)
- local Weld = Instance.new("Weld", Box)
- Weld.Part0 = Box
- Weld.Part1 = player.Character.HumanoidRootPart
- Weld.C0 = Box.CFrame:Inverse() * player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, boxDist)
- local anim = game.ReplicatedStorage.Animations.HoldBox
- Animations[plr]["Holding Box"] = player.Character.Humanoid.Animator:LoadAnimation(anim)
- Animations[plr]["Holding Box"]:Play()
- JobRemotes.HighlightItem:FireClient(plr, IceCream.ClickDetectors.IceCreamStock)
- JobRemotes.ShowArrow:FireClient(plr, IceCream.ClickDetectors.IceCreamStock)
- JobRemotes.ActivateClickDetector:FireClient(plr, IceCream.ClickDetectors.IceCreamStock.ClickDetector, true)
- local connection2
- connection2 = IceCream.ClickDetectors.IceCreamStock.ClickDetector.MouseClick:Connect(function(player)
- if plr.Character:FindFirstChild("Box") then
- plr.Character:FindFirstChild("Box"):Destroy()
- Animations[plr]["Holding Box"]:Stop()
- Animations[plr]["Holding Box"] = nil
- end
- JobRemotes.ActivateClickDetector:FireClient(plr, IceCream.ClickDetectors.IceCreamStock.ClickDetector, false)
- inStock = true
- JobRemotes.HighlightItem:FireClient(plr)
- JobRemotes.ShowArrow:FireClient(plr)
- RoleStocks[plr] = 0
- connection2:Disconnect()
- end)
- table.insert(PlayerConnections[plr], connection2)
- connection:Disconnect()
- end)
- table.insert(PlayerConnections[plr], connection)
- repeat task.wait()
- if connection == nil then
- break
- end
- until inStock
- end
- if inStock == true then
- JobRemotes.FlavorsTransparency:FireClient(plr, IceCream["Ice cream shop"].Flavs.Flavors:GetChildren(), RoleStocks[plr] / MaxStock)
- local CustomerModels = game.ReplicatedStorage.Customers:GetChildren()
- local Customer = CustomerModels[math.random(1, #CustomerModels)]:Clone()
- Customer.Parent = workspace.JobSystem.PlayerCustomers
- for i, v: BasePart in pairs(Customer:GetDescendants()) do
- if v:IsA("BasePart") then
- v.CollisionGroup = "Customers"
- end
- end
- local Host = Instance.new("ObjectValue", Customer)
- Host.Name = "Host"
- Host.Value = plr
- local Humanoid: Humanoid = Customer.Humanoid
- local Waypoints = IceCream.Waypoints.FlavorPicker["FP"..station]
- Customer.HumanoidRootPart.CFrame = Waypoints:FindFirstChild("1").CFrame
- CreatePath(Customer, Waypoints:FindFirstChild("5").Position)
- local suffix = ListOfCustomerMsgs.Suffix[JobName][math.random(1, #ListOfCustomerMsgs.Suffix[JobName])]
- local CustomerTag = script.CustomerTag:Clone()
- CustomerTag.Parent = Customer.Head
- CustomerTag.Frame.Icon.Image = suffix.Icon
- for i = 1, #IceCream.ClickDetectors.FlavorPicker:GetChildren() do
- local flavor = IceCream.ClickDetectors.FlavorPicker:FindFirstChild(i)
- if flavor then
- local connection
- JobRemotes.ActivateClickDetector:FireClient(plr, flavor.ClickDetector, true)
- connection = flavor.ClickDetector.MouseClick:Connect(function(player)
- if player ~= plr then return end
- local PHum = plr.Character:WaitForChild("Humanoid")
- local Animation = game:GetService("ReplicatedStorage").Animations["Ice Cream"].Picking
- local PlayAni = PHum:WaitForChild("Animator"):LoadAnimation(Animation)
- PlayAni:Play()
- connection:Disconnect()
- CustomerTag:Destroy()
- if tonumber(i) == tonumber(suffix.Order) then
- if Customer:FindFirstChild("Head") == nil then return end
- ChatService:Chat(Customer:WaitForChild("Head"), "Thanks for the Ice Cream 🍦!!", Enum.ChatColor.White)
- IceCreamJob:Pay(plr)
- task.wait(1)
- Customer:Destroy()
- print("Customer Destroyed1")
- coroutine.wrap(function()
- FlavorPickerAction(table.unpack(pack))
- end)()
- else
- if Customer:FindFirstChild("Head") == nil then return end
- ChatService:Chat(Customer:WaitForChild("Head"), "Ugh, you got my order wrong!!", Enum.ChatColor.White)
- task.wait(1)
- Customer:Destroy()
- print("Customer Destroyed2")
- coroutine.wrap(function()
- FlavorPickerAction(table.unpack(pack))
- end)()
- end
- RoleStocks[plr] += 1--ERRRRROOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOORRRRRRRRRRRRR
- end)
- table.insert(PlayerConnections[plr], connection)
- end
- end
- end
- end
- local MaxStock = 7
- function ToppingsPickerAction(...)
- print('Toppings')
- local pack = table.pack(...)
- local JobName = pack[1]
- local EventName = pack[2]
- local plr = pack[3]
- local station = pack[4]
- if not HasJob(plr) then return end
- JobRemotes.ActivateClickDetector:FireClient(plr, IceCream.ClickDetectors.ToppingsStock.ClickDetector, false)
- local inStock = true
- if RoleStocks[plr] >= MaxStock then
- inStock = false
- JobRemotes.ActivateClickDetector:FireClient(plr, IceCream.ClickDetectors.Toppings.ClickDetector, true)
- JobRemotes.ShowArrow:FireClient(plr, IceCream.ClickDetectors.Toppings)
- local connection
- connection = IceCream.ClickDetectors.Toppings.ClickDetector.MouseClick:Connect(function(player)
- if player ~= plr then return end
- local PHum = plr.Character:WaitForChild("Humanoid")
- local Animation = game:GetService("ReplicatedStorage").Animations["Ice Cream"].Picking
- local PlayAni = PHum:WaitForChild("Animator"):LoadAnimation(Animation)
- PlayAni:Play()
- local boxDist = 1
- local Box = game.ReplicatedStorage.Tools["Ice Cream"].Box:Clone()
- Box.Parent = player.Character
- Box.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, boxDist)
- local Weld = Instance.new("Weld", Box)
- Weld.Part0 = Box
- Weld.Part1 = player.Character.HumanoidRootPart
- Weld.C0 = Box.CFrame:Inverse() * player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, boxDist)
- local anim = game.ReplicatedStorage.Animations.HoldBox
- Animations[plr]["Holding Box"] = player.Character.Humanoid.Animator:LoadAnimation(anim)
- Animations[plr]["Holding Box"]:Play()
- JobRemotes.ShowArrow:FireClient(plr, IceCream.ClickDetectors.ToppingsStock)
- JobRemotes.ActivateClickDetector:FireClient(plr, IceCream.ClickDetectors.ToppingsStock.ClickDetector, true)
- local connection2
- connection2 = IceCream.ClickDetectors.ToppingsStock.ClickDetector.MouseClick:Connect(function(player)
- if plr.Character:FindFirstChild("Box") then
- plr.Character:FindFirstChild("Box"):Destroy()
- Animations[plr]["Holding Box"]:Stop()
- Animations[plr]["Holding Box"] = nil
- end
- inStock = true
- JobRemotes.ShowArrow:FireClient(plr)
- JobRemotes.ActivateClickDetector:FireClient(plr, IceCream.ClickDetectors.ToppingsStock.ClickDetector, false)
- RoleStocks[plr] = 0
- connection2:Disconnect()
- end)
- table.insert(PlayerConnections[plr], connection2)
- connection:Disconnect()
- end)
- table.insert(PlayerConnections[plr], connection)
- repeat task.wait()
- if connection == nil then
- break
- end
- until inStock
- end
- if inStock == true then
- print(inStock)
- print(RoleStocks[plr])
- local Customer: Model = game.ReplicatedStorage.Customers:GetChildren()
- Customer = Customer[math.random(1, #Customer)]:Clone()
- Customer.Parent = workspace.JobSystem.PlayerCustomers
- for i, v: BasePart in pairs(Customer:GetDescendants()) do
- if v:IsA("BasePart") then
- v.CollisionGroup = "Customers"
- end
- end
- local Host = Instance.new("ObjectValue", Customer)
- Host.Name = "Host"
- Host.Value = plr
- local Humanoid: Humanoid = Customer.Humanoid
- local Waypoints = IceCream.Waypoints.ToppingsPicker["TP"..station]
- Customer.HumanoidRootPart.CFrame = Waypoints:FindFirstChild("1").CFrame
- CreatePath(Customer, Waypoints:FindFirstChild("5").Position)
- local num = math.random(1, #ListOfCustomerMsgs.Suffix[JobName])
- local suffix = ListOfCustomerMsgs.Suffix[JobName][num]
- local Order = Orders.Clone(Orders.IceCream.Order[num])
- local CustomerTag = script.CustomerTag:Clone()
- CustomerTag.Parent = Customer:WaitForChild('Head')
- CustomerTag.Frame.Icon.Image = suffix.Icon
- local isRunning = true
- local isOnNumber = 1
- local NameOfStage = ""
- for i, v in pairs(IceCream.ClickDetectors.ToppingsPicker:GetChildren()) do
- local isCorrect = false -- whether it is on the recipe
- for j, k in pairs(Order.Clicks) do
- if k.Name == v.Name then
- isCorrect = true
- end
- end
- if not isCorrect then
- local connection
- JobRemotes.ActivateClickDetector:FireClient(plr, v.ClickDetector, true)
- connection = v.ClickDetector.MouseClick:Connect(function(player)
- if player ~= plr then return end
- if Customer:FindFirstChild('Head') == nil then
- return
- end
- CustomerTag:Destroy()
- ChatService:Chat(Customer:WaitForChild('Head'), "Ugh, you got my order wrong!!", Enum.ChatColor.White)
- connection:Disconnect()
- task.wait(1)
- Customer:Destroy()
- isRunning = false
- RoleStocks[plr] += 1
- ToppingsPickerAction(table.unpack(pack))
- end)
- table.insert(PlayerConnections[plr], connection)
- end
- end
- for i = 1, #Order.Clicks, 1 do
- local Stage = Order.Clicks[i]
- local v = IceCream.ClickDetectors.ToppingsPicker[Stage.Name]
- local connection
- if i == 1 then
- JobRemotes.ShowArrow:FireClient(plr, v)
- end
- JobRemotes.ActivateClickDetector:FireClient(plr, v.ClickDetector, true)
- connection = v.ClickDetector.MouseClick:Connect(function(player)
- if player ~= plr then return end
- if i ~= 1 then
- local clminus = Order.Clicks[i - 1] -- Current one minus 1 (to go back)
- if clminus then
- if not clminus.Done then
- isRunning = false
- ToppingsPickerAction(table.unpack(pack))
- connection:Disconnect()
- return
- end
- end
- end
- connection:Disconnect()
- isOnNumber += 1
- if i ~= #Order.Clicks then
- NameOfStage = Order.Clicks[i+1].Name
- end
- print(i)
- if i == #Order.Clicks then
- JobRemotes.ShowArrow:FireClient(plr)
- isRunning = false
- RoleStocks[plr] += 1
- CustomerTag:Destroy()
- IceCreamJob:Pay(plr)
- if Customer:FindFirstChild('Head') ~= nil then
- ChatService:Chat(Customer.Head, "Thanks for the Ice Cream 🍦!!", Enum.ChatColor.White)
- end
- task.wait(1)
- Customer:Destroy()
- ToppingsPickerAction(table.unpack(pack))
- end
- Order.Clicks[i].Done = true
- end)
- table.insert(PlayerConnections[plr], connection)
- end
- coroutine.wrap(function()
- while isRunning do
- if #PlayerConnections[plr] == 0 then
- break
- end
- if isOnNumber ~= 1 then
- JobRemotes.ShowArrow:FireClient(plr, IceCream.ClickDetectors.ToppingsPicker[NameOfStage])
- end
- task.wait()
- end
- RoleStocks[plr] += 1
- end)()
- end
- end
- function QuitJob(...)
- local pack = table.pack(...)
- local JobName = pack[1]
- local EventName = pack[2]
- local plr = pack[3]
- if not HasJob(plr) then return end
- JobRemotes.FlavorsTransparency:FireClient(plr, IceCream["Ice cream shop"].Flavs.Flavors:GetChildren(), 0)
- local pay = 0
- local memo = ""
- if JobName == HallaPizzaJob.JobName then
- -- Paycheck
- pay = HallaPizzaJob:GetPlayerPay(plr)
- memo = "HP WORKER"
- HallaPizzaJob.RemoveWorker(plr)
- local Registers = HallaPizza.Registers
- -- Reset Registers if they are a Cashier
- if Registers.Register1.Owner.Value == plr then
- Registers.Register1.Owner.Value = nil
- elseif Registers.Register2.Owner.Value == plr then
- Registers.Register2.Owner.Value = nil
- end
- local DM = HallaPizza.ObjectValues.DoughMaker -- Dough Maker Object Values
- local DMC = HallaPizza.ClickDetectors.DoughMaker -- Dough Maker ClickDetectors
- if DM.Table1.Host.Value == plr then
- DM.Table1.Host.Value = nil
- JobRemotes.ActivateClickDetector:FireClient(plr, DMC.Table1.ClickDetector, false)
- elseif DM.Table2.Host.Value == plr then
- DM.Table2.Host.Value = nil
- JobRemotes.ActivateClickDetector:FireClient(plr, DMC.Table2.ClickDetector, false)
- end
- local PM = HallaPizza.ObjectValues.PizzaMaker -- Pizza Maker Object Values
- local PMC = HallaPizza.ClickDetectors.PizzaMaker -- Pizza Maker ClickDetectors
- local PMI = HallaPizza.PizzaMakerItems
- if PM.Table1.Host.Value == plr then
- PM.Table1.Host.Value = nil
- PM.Screen1.Value.GUI.Icon.Image = ""
- JobRemotes.ActivateClickDetector:FireClient(plr, PMC.Table1.ClickDetector, false)
- changeModelTranparency(PMI.Pizza1, 1)
- elseif PM.Table2.Host.Value == plr then
- PM.Table2.Host.Value = nil
- PM.Screen2.Value.GUI.Icon.Image = ""
- JobRemotes.ActivateClickDetector:FireClient(plr, PMC.Table2.ClickDetector, false)
- changeModelTranparency(PMI.Pizza2, 1)
- end
- -- Reset Player Worker Count
- local workers = HallaPizzaJob:GetRoleTotalWorkers("Cashier")
- local maxWorkers = HallaPizzaJob:GetRoleMaxWorkers("Cashier")
- HallaPizza.ClaimParts.CashRegister.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
- workers = HallaPizzaJob:GetRoleTotalWorkers("Pizza Runner")
- maxWorkers = HallaPizzaJob:GetRoleMaxWorkers("Pizza Runner")
- HallaPizza.ClaimParts.PizzaRunner.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
- local workers = HallaPizzaJob:GetRoleTotalWorkers("Dough Maker")
- local maxWorkers = HallaPizzaJob:GetRoleMaxWorkers("Dough Maker")
- HallaPizza.ClaimParts.DoughMaker.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
- local workers = HallaPizzaJob:GetRoleTotalWorkers("Pizza Maker")
- local maxWorkers = HallaPizzaJob:GetRoleMaxWorkers("Pizza Maker")
- HallaPizza.ClaimParts.PizzaMaker.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
- elseif JobName == RestaurantJob.JobName then
- -- Paycheck
- pay = RestaurantJob:GetPlayerPay(plr)
- memo = "Restaurant Worker"
- RestaurantJob.RemoveWorker(plr)
- -- Reset Player Worker Count
- local workers = RestaurantJob:GetRoleTotalWorkers("Cashier")
- local maxWorkers = RestaurantJob:GetRoleMaxWorkers("Cashier")
- Restaurant.ClaimParts.CashRegister.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
- -- Reset Player Worker Count
- local workers = RestaurantJob:GetRoleTotalWorkers("Delivery")
- local maxWorkers = RestaurantJob:GetRoleMaxWorkers("Delivery")
- Restaurant.ClaimParts.Delivery.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
- -- Reset Player Worker Count
- local workers = RestaurantJob:GetRoleTotalWorkers("Dish Washer")
- local maxWorkers = RestaurantJob:GetRoleMaxWorkers("Dish Washer")
- Restaurant.ClaimParts.DishWasher.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
- -- Reset Player Worker Count
- local workers = RestaurantJob:GetRoleTotalWorkers("Cooker")
- local maxWorkers = RestaurantJob:GetRoleMaxWorkers("Cooker")
- Restaurant.ClaimParts.Cooker.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
- -- Reset Player Worker Count
- local workers = RestaurantJob:GetRoleTotalWorkers("Chopper")
- local maxWorkers = RestaurantJob:GetRoleMaxWorkers("Chopper")
- Restaurant.ClaimParts.Chopper.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
- elseif JobName == IceCreamJob.JobName then
- -- Paycheck
- pay = IceCreamJob:GetPlayerPay(plr)
- memo = "Ice Cream Worker"
- IceCreamJob.RemoveWorker(plr)
- -- Reset Player Worker Count
- local workers = IceCreamJob:GetRoleTotalWorkers("Flavor Picker")
- local maxWorkers = IceCreamJob:GetRoleMaxWorkers("Flavor Picker")
- IceCream.ClaimParts.FlavorPicker.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
- -- Reset Player Worker Count
- local workers = IceCreamJob:GetRoleTotalWorkers("Toppings Picker")
- local maxWorkers = IceCreamJob:GetRoleMaxWorkers("Toppings Picker")
- IceCream.ClaimParts.ToppingsPicker.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
- -- Reset Player Worker Count
- local workers = IceCreamJob:GetRoleTotalWorkers("Cashier")
- local maxWorkers = IceCreamJob:GetRoleMaxWorkers("Cashier")
- IceCream.ClaimParts.CashRegister.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
- end
- for i, v:ProximityPrompt in pairs(workspace.JobSystem[JobName].ClaimParts:GetDescendants()) do
- if v:IsA("ProximityPrompt") then
- JobRemotes.ActivatePrompt:FireClient(plr, v, true)
- end
- end
- local CanReceivePay = true
- if pay > 0 then
- JobRemotes.ShowPaycheck:FireClient(plr, pay, memo)
- JobRemotes.GivePaycheck.OnServerEvent:Connect(function(player)
- if CanReceivePay == true then
- CanReceivePay = false
- player.leaderstats:FindFirstChild("Hallabucks").Value += pay
- end
- end)
- end
- -- Disconnect all RBX Events
- for i, v in pairs(PlayerConnections[plr]) do
- v:Disconnect()
- PlayerConnections[plr][i] = nil
- end
- RoleStocks[plr] = 0
- -- Destroy all Player Customers owned by this player
- for i, v in pairs(workspace.JobSystem.PlayerCustomers:GetChildren()) do
- if v:FindFirstChild("Host") then
- if v:FindFirstChild("Host").Value == plr then
- v:Destroy()
- end
- end
- end
- -- Stop showing an arrow
- JobRemotes.ShowArrow:FireClient(plr)
- plr.PlayerGui.CashierGui.Adornee = nil
- plr.PlayerGui.CashierGui2.Adornee = nil
- if plr.Character:FindFirstChild("Box") then
- plr.Character:FindFirstChild("Box"):Destroy()
- Animations[plr]["Holding Box"]:Stop()
- Animations[plr]["Holding Box"] = nil
- end
- for i, v in pairs(workspace.JobSystem:GetDescendants()) do
- if v:IsA("ClickDetector") then
- JobRemotes.ActivateClickDetector:FireClient(plr, v, false)
- end
- end
- plr.Character.Humanoid.WalkSpeed = game.StarterPlayer.CharacterWalkSpeed
- plr.Character.Humanoid.JumpPower = game.StarterPlayer.CharacterJumpPower
- JobRemotes.ShowFrames:FireClient(plr, false)
- if plr.Character:FindFirstChildWhichIsA("Folder") then
- task.spawn(function()
- plr.Character:FindFirstChildWhichIsA("Folder"):Destroy()
- end)
- end
- end
- -- Create Events
- -- HallaPizza
- HallaPizzaJob:CreateEvent("StartJob", StartJob)
- HallaPizzaJob:CreateEvent("QuitJob", QuitJob)
- HallaPizzaJob:CreateRoleAction("Cashier", "Cashier Customer", CashierCustomerAction)
- HallaPizzaJob:CreateRoleAction("Pizza Runner", "PR Customer", CustomerAction2)
- HallaPizzaJob:CreateRoleAction("Dough Maker", "Dough Maker Action", DoughMakerAction)
- HallaPizzaJob:CreateRoleAction("Pizza Maker", "Pizza Maker Action", PizzaMakerAction)
- -- Restaurant
- RestaurantJob:CreateEvent("StartJob", StartJob)
- --RestaurantJob:CreateEvent("ChangeRole", ChangeRole)
- RestaurantJob:CreateEvent("QuitJob", QuitJob)
- RestaurantJob:CreateRoleAction("Cashier", "Cashier Customer", CashierCustomerAction)
- RestaurantJob:CreateRoleAction("Delivery", "CustomerAction2", CustomerAction2)
- RestaurantJob:CreateRoleAction("Dish Washer", "Dish Washer Action", DishWasherAction)
- RestaurantJob:CreateRoleAction("Cooker", "Cooker Action", CookerAction)
- RestaurantJob:CreateRoleAction("Chopper", "Chopper Action", ChopperAction)
- -- Ice Cream
- IceCreamJob:CreateEvent("StartJob", StartJob)
- --IceCreamJob:CreateEvent("ChangeRole", ChangeRole)
- IceCreamJob:CreateEvent("QuitJob", QuitJob)
- IceCreamJob:CreateRoleAction("Cashier", "Cashier Customer", CashierCustomerAction)
- IceCreamJob:CreateRoleAction("Flavor Picker", "Flavor Picker Action", FlavorPickerAction)
- IceCreamJob:CreateRoleAction("Toppings Picker", "Toppings Picker Action", ToppingsPickerAction)
- ---------------------------------------------------------------
- -- Prompt Events
- ---------------------------------------------------------------
- ---------------------- HallaPizza -----------------------------
- HallaPizza.EndShift.Touched:Connect(function(hit)
- local player = game.Players:GetPlayerFromCharacter(hit.Parent)
- if player then
- HallaPizzaJob:FireEvent("QuitJob", player)
- end
- end)
- -- Cashier -----------------------------------------------------
- local Registers = HallaPizza.Registers
- HallaPizza.ClaimParts.CashRegister.ProximityPrompt.Triggered:Connect(function(player)
- HallaPizzaJob:FireEvent("StartJob", player, "Cashier")
- if Registers.Register1.Owner.Value == nil then
- Registers.Register1.Owner.Value = player
- elseif Registers.Register2.Owner.Value == nil then
- Registers.Register2.Owner.Value = player
- end
- local workers = HallaPizzaJob:GetRoleTotalWorkers("Cashier")
- local maxWorkers = HallaPizzaJob:GetRoleMaxWorkers("Cashier")
- HallaPizza.ClaimParts.CashRegister.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
- HallaPizzaJob:FireRoleAction("Cashier", "Cashier Customer", player)
- end)
- -- Pizza Runner -----------------------------------------------
- HallaPizza.ClaimParts.PizzaRunner.ProximityPrompt.Triggered:Connect(function(player)
- HallaPizzaJob:FireEvent("StartJob", player, "Pizza Runner")
- local workers = HallaPizzaJob:GetRoleTotalWorkers("Pizza Runner")
- local maxWorkers = HallaPizzaJob:GetRoleMaxWorkers("Pizza Runner")
- HallaPizza.ClaimParts.PizzaRunner.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
- HallaPizzaJob:FireRoleAction("Pizza Runner", "PR Customer", player)
- end)
- -- Dough Maker -----------------------------------------------
- HallaPizza.ClaimParts.DoughMaker.ProximityPrompt.Triggered:Connect(function(player)
- HallaPizzaJob:FireEvent("StartJob", player, "Dough Maker")
- local workers = HallaPizzaJob:GetRoleTotalWorkers("Dough Maker")
- local maxWorkers = HallaPizzaJob:GetRoleMaxWorkers("Dough Maker")
- HallaPizza.ClaimParts.DoughMaker.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
- local DM = HallaPizza.ObjectValues.DoughMaker -- Dough Maker Object Values
- if DM.Table1.Host.Value ~= nil then
- DM.Table1.Host.Value = player
- elseif DM.Table2.Host.Value ~= nil then
- DM.Table2.Host.Value = player
- end
- HallaPizzaJob:FireRoleAction("Dough Maker", "Dough Maker Action", player, HallaPizzaJob:GetRoleTotalWorkers("Dough Maker"))
- end)
- -- Pizza Maker -----------------------------------------------
- HallaPizza.ClaimParts.PizzaMaker.ProximityPrompt.Triggered:Connect(function(player)
- HallaPizzaJob:FireEvent("StartJob", player, "Pizza Maker")
- local workers = HallaPizzaJob:GetRoleTotalWorkers("Pizza Maker")
- local maxWorkers = HallaPizzaJob:GetRoleMaxWorkers("Pizza Maker")
- HallaPizza.ClaimParts.PizzaMaker.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
- local PM = HallaPizza.ObjectValues.PizzaMaker -- Dough Maker Object Values
- if PM.Table1.Host.Value == nil then
- PM.Table1.Host.Value = player
- elseif PM.Table2.Host.Value == nil then
- PM.Table2.Host.Value = player
- end
- HallaPizzaJob:FireRoleAction("Pizza Maker", "Pizza Maker Action", player, HallaPizzaJob:GetRoleTotalWorkers("Pizza Maker"))
- end)
- ---------------------- Restaurant -----------------------------
- Restaurant.EndShift.Touched:Connect(function(hit)
- local player = game.Players:GetPlayerFromCharacter(hit.Parent)
- if player then
- RestaurantJob:FireEvent("QuitJob", player)
- end
- end)
- -- Cashier -----------------------------------------------------
- local Registers = Restaurant.Registers
- Restaurant.ClaimParts.CashRegister.ProximityPrompt.Triggered:Connect(function(player)
- RestaurantJob:FireEvent("StartJob", player, "Cashier")
- if Registers.Register1.Owner.Value == nil then
- Registers.Register1.Owner.Value = player
- elseif Registers.Register2.Owner.Value == nil then
- Registers.Register2.Owner.Value = player
- end
- local workers = RestaurantJob:GetRoleTotalWorkers("Cashier")
- local maxWorkers = RestaurantJob:GetRoleMaxWorkers("Cashier")
- Restaurant.ClaimParts.CashRegister.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
- RestaurantJob:FireRoleAction("Cashier", "Cashier Customer", player)
- end)
- -- Delivery -----------------------------------------------
- Restaurant.ClaimParts.Delivery.ProximityPrompt.Triggered:Connect(function(player)
- RestaurantJob:FireEvent("StartJob", player, "Delivery")
- local workers = RestaurantJob:GetRoleTotalWorkers("Delivery")
- local maxWorkers = RestaurantJob:GetRoleMaxWorkers("Delivery")
- Restaurant.ClaimParts.Delivery.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
- RestaurantJob:FireRoleAction("Delivery", "CustomerAction2", player)
- end)
- -- Dish Washer -----------------------------------------------
- Restaurant.ClaimParts.DishWasher.ProximityPrompt.Triggered:Connect(function(player)
- RestaurantJob:FireEvent("StartJob", player, "Dish Washer")
- local workers = RestaurantJob:GetRoleTotalWorkers("Dish Washer")
- local maxWorkers = RestaurantJob:GetRoleMaxWorkers("Dish Washer")
- Restaurant.ClaimParts.DishWasher.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
- RestaurantJob:FireRoleAction("Dish Washer", "Dish Washer Action", player, RestaurantJob:GetRoleTotalWorkers("Dish Washer"))
- end)
- -- Cooker -----------------------------------------------
- Restaurant.ClaimParts.Cooker.ProximityPrompt.Triggered:Connect(function(player)
- RestaurantJob:FireEvent("StartJob", player, "Cooker")
- local workers = RestaurantJob:GetRoleTotalWorkers("Cooker")
- local maxWorkers = RestaurantJob:GetRoleMaxWorkers("Cooker")
- Restaurant.ClaimParts.Cooker.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
- RestaurantJob:FireRoleAction("Cooker", "Cooker Action", player)
- end)
- -- Chopper -----------------------------------------------
- Restaurant.ClaimParts.Chopper.ProximityPrompt.Triggered:Connect(function(player)
- RestaurantJob:FireEvent("StartJob", player, "Chopper")
- local workers = RestaurantJob:GetRoleTotalWorkers("Chopper")
- local maxWorkers = RestaurantJob:GetRoleMaxWorkers("Chopper")
- Restaurant.ClaimParts.Chopper.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
- RestaurantJob:FireRoleAction("Chopper", "Chopper Action", player, RestaurantJob:GetRoleTotalWorkers("Chopper"))
- end)
- ---------------------- Ice Cream Shop -----------------------------
- IceCream.EndShift.Touched:Connect(function(hit)
- local player = game.Players:GetPlayerFromCharacter(hit.Parent)
- if player then
- IceCreamJob:FireEvent("QuitJob", player)
- end
- end)
- -- Cashier -----------------------------------------------------
- local Registers = IceCream.Registers
- IceCream.ClaimParts.CashRegister.ProximityPrompt.Triggered:Connect(function(player)
- IceCreamJob:FireEvent("StartJob", player, "Cashier")
- if Registers.Register1.Owner.Value == nil then
- Registers.Register1.Owner.Value = player
- elseif Registers.Register2.Owner.Value == nil then
- Registers.Register2.Owner.Value = player
- end
- local workers = IceCreamJob:GetRoleTotalWorkers("Cashier")
- local maxWorkers = IceCreamJob:GetRoleMaxWorkers("Cashier")
- IceCream.ClaimParts.CashRegister.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
- IceCreamJob:FireRoleAction("Cashier", "Cashier Customer", player)
- end)
- IceCream.ClaimParts.FlavorPicker.ProximityPrompt.Triggered:Connect(function(player)
- IceCreamJob:FireEvent("StartJob", player, "Flavor Picker")
- local workers = IceCreamJob:GetRoleTotalWorkers("Flavor Picker")
- local maxWorkers = IceCreamJob:GetRoleMaxWorkers("Flavor Picker")
- IceCream.ClaimParts.FlavorPicker.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
- IceCreamJob:FireRoleAction("Flavor Picker", "Flavor Picker Action", player, IceCreamJob:GetRoleTotalWorkers("Flavor Picker"))
- end)
- IceCream.ClaimParts.ToppingsPicker.ProximityPrompt.Triggered:Connect(function(player)
- IceCreamJob:FireEvent("StartJob", player, "Toppings Picker")
- local workers = IceCreamJob:GetRoleTotalWorkers("Toppings Picker")
- local maxWorkers = IceCreamJob:GetRoleMaxWorkers("Toppings Picker")
- IceCream.ClaimParts.ToppingsPicker.BillboardGui.TextLabel.Text = workers .. "/" .. maxWorkers
- IceCreamJob:FireRoleAction("Toppings Picker", "Toppings Picker Action", player, IceCreamJob:GetRoleTotalWorkers("Toppings Picker"))
- end)
- ---------------------------------------------------------------
- -- ClickDetector Events
- ---------------------------------------------------------------
- for i, v in pairs(HallaPizza.ClickDetectors.Pizza:GetChildren()) do
- if v:IsA("BasePart") then
- local clickDetector: ClickDetector = v:FindFirstChild("ClickDetector")
- if clickDetector then
- clickDetector.MouseClick:Connect(function(player)
- if HallaPizzaJob:IsRoleWorker("Pizza Runner", player) then
- local tool = game.ReplicatedStorage.Tools.HallaPizza.Pizza:FindFirstChild(v.Name)
- local anim = game.ReplicatedStorage.Animations.HallaPizza.HoldPizza
- if tool and anim then
- tool = tool:Clone()
- tool.Parent = player.Character
- tool.Handle.CFrame *= CFrame.new(0, 0, 2)
- local Weld = Instance.new("Weld", tool.Handle)
- Weld.Part0 = tool.Handle
- Weld.Part1 = player.Character.RightHand
- Weld.C0 = tool.Handle.CFrame:Inverse() * player.Character.RightHand.CFrame * CFrame.Angles(math.rad(180), 0, 0)
- Animations[player]["Holding Pizza"] = player.Character.Humanoid.Animator:LoadAnimation(anim)
- Animations[player]["Holding Pizza"]:Play()
- end
- end
- end)
- end
- end
- end
- for i, v in pairs(Restaurant.ClickDetectors.Meals:GetChildren()) do
- if v:IsA("BasePart") then
- local clickDetector: ClickDetector = v:FindFirstChild("ClickDetector")
- if clickDetector then
- clickDetector.MouseClick:Connect(function(player)
- if RestaurantJob:IsRoleWorker("Delivery", player) then
- local tool = game.ReplicatedStorage.Tools.Restaurant.Meals:FindFirstChild(v.Name)
- print(v.Name)
- print(tool)
- local anim = game.ReplicatedStorage.Animations.Restaurant.HoldMeal
- if tool and anim then
- tool = tool:Clone()
- tool.Parent = player.Character
- tool.Handle.CFrame *= CFrame.new(0, 0, 2)
- local Weld = Instance.new("Weld", tool.Handle)
- Weld.Part0 = tool.Handle
- Weld.Part1 = player.Character.RightHand
- Weld.C0 = tool.Handle.CFrame:Inverse() * player.Character.RightHand.CFrame * CFrame.Angles(math.rad(30), 0, 0) * CFrame.new(0, 0.5, 1)
- Animations[player]["Holding Plate"] = player.Character.Humanoid.Animator:LoadAnimation(anim)
- Animations[player]["Holding Plate"]:Play()
- end
- end
- end)
- end
- end
- end
- JobRemotes.QuitJob.OnServerEvent:Connect(function(player)
- if HallaPizzaJob:IsWorker(player) then
- HallaPizzaJob:FireEvent("QuitJob", player)
- end
- if RestaurantJob:IsWorker(player) then
- RestaurantJob:FireEvent("QuitJob", player)
- end
- if IceCreamJob:IsWorker(player) then
- IceCreamJob:FireEvent("QuitJob", player)
- end
- end)
- game["Run Service"].Heartbeat:Connect(function()
- game["Run Service"].Heartbeat:Wait()
- for i, v in pairs(game.Players:GetChildren()) do
- local player = v
- local Pay = 0
- local IsWorker = false
- if HallaPizzaJob:IsWorker(player) then
- Pay = HallaPizzaJob:GetPlayerPay(player)
- IsWorker = true
- end
- if RestaurantJob:IsWorker(player) then
- Pay = RestaurantJob:GetPlayerPay(player)
- IsWorker = true
- end
- if IceCreamJob:IsWorker(player) then
- Pay = IceCreamJob:GetPlayerPay(player)
- IsWorker = true
- end
- if IsWorker then
- JobRemotes.ShowStats:FireClient(player, Pay)
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement