local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local directory = workspace.CafeMachines
local authorizedItems = {
--CUPS
"Large Cone";
"Medium Cone";
"Small Cone";
"Large Cup";
"Medium Cup";
"Small Cup";
"Large Glass";
"Medium Glass";
"Small Glass";
"Large Mug";
"Medium Mug";
"Small Mug";
--COFFEE
"Americano";
"Cappuccino";
"Decaf";
"Espresso";
"Frappe";
"Latte";
"Macchiato";
"Mocha";
"Regular";
--ADDONS
"Blender";
"Cream";
"MilkCarton";
"Sugar";
"Water";
}
local authorizedMachines = {
"AmericanoMachine";
"CappuccinoMachine";
"DecafMachine";
"EspressoMachine";
"FrappeMachine";
"LatteMachine";
"MacchiatoMachine";
"MochaMachine";
"RegularMachine";
"Water";
"AssamTea";
"GreenTea";
"OolongTea";
"WhiteTea";
"ChocolateIceCream";
"MintIceCream";
"StrawberryIceCream";
"VanillaIceCream";
"MilkCarton";
"BananaMilkshake";
"BlueberryMilkshake";
"LemonMilkshake";
"LimeMilkshake";
"OrangeMilkshake";
"StrawberryMilkshake";
"Blender";
"Ice";
"Sugar";
}
local machineRequirements = {
["AmericanoMachine"] = {MachineName = "AmericanoMachine", acceptedItems = {"Small Cup", "Medium Cup", "Large Cup"}, product = "Americano"},
["CappuccinoMachine"] = {MachineName = "CappuccinoMachine", acceptedItems = {"Small Cup", "Medium Cup", "Large Cup"}, product = "Cappucino"},
["DecafMachine"] = {MachineName = "DecafMachine", acceptedItems = {"Small Cup", "Medium Cup", "Large Cup"}, product = "Decaf"},
["EspressoMachine"] = {MachineName = "EspressoMachine", acceptedItems = {"Small Cup", "Medium Cup", "Large Cup"}, product = "Espresso"},
["FrappeMachine"] = {MachineName = "FrappeMachine", acceptedItems = {"Small Cup", "Medium Cup", "Large Cup"}, product = "Frappe"},
["LatteMachine"] = {MachineName = "LatteMachine", acceptedItems = {"Espresso"}, product = "Latte"},
["MacchiatoMachine"] = {MachineName = "MacchiatoMachine", acceptedItems = {"Small Cup", "Medium Cup", "Large Cup"}, product = "Macchiato"},
["MochaMachine"] = {MachineName = "MochaMachine", acceptedItems = {"Small Cup", "Medium Cup", "Large Cup"}, product = "Mocha"},
["RegularMachine"] = {MachineName = "RegularMachine", acceptedItems = {"Small Cup", "Medium Cup", "Large Cup"}, product = "Regular"},
["Water"] = {MachineName = "Water", acceptedItems = {"Small Mug", "Medium Mug", "Large Mug"}, product = "Mug of Water"},
["AssamTea"] = {MachineName = "AssamTea", acceptedItems = {"Mug of Water"}, product = "Mug of Assam Tea"},
["GreenTea"] = {MachineName = "GreenTea", acceptedItems = {"Mug of Water"}, product = "Mug of Green Tea"},
["OolongTea"] = {MachineName = "OolongTea", acceptedItems = {"Mug of Water"}, product = "Mug of Oolong Tea"},
["WhiteTea"] = {MachineName = "WhiteTea", acceptedItems = {"Mug of Water"}, product = "Mug of White Tea"},
["ChocolateIceCream"] = {MachineName = "ChocolateIceCream", acceptedItems = {"Small Cone", "Medium Cone", "Large Cone"}, product = "Chocolate Ice Cream"},
["MintIceCream"] = {MachineName = "MintIceCream", acceptedItems = {"Small Cone", "Medium Cone", "Large Cone"}, product = "Mint Ice Cream"},
["StrawberryIceCream"] = {MachineName = "StrawberryIceCream", acceptedItems = {"Small Cone", "Medium Cone", "Large Cone"}, product = "Strawberry Ice Cream"},
["VanillaIceCream"] = {MachineName = "VanillaIceCream", acceptedItems = {"Small Cone", "Medium Cone", "Large Cone"}, product = "Vanilla Ice Cream"},
["MilkCarton"] = {MachineName = "MilkCarton", acceptedItems = {"Small Glass", "Medium Glass", "Large Glass"}, product = "Glass of Milk"},
["BananaMilkshake"] = {MachineName = "BananaMilkshake", acceptedItems = {"Glass of Milk"}, product = "Banana Milkshake"},
["BlueberryMilkshake"] = {MachineName = "BlueberryMilkshake", acceptedItems = {"Glass of Milk"}, product = "Blueberry Milkshake"},
["LemonMilkshake"] = {MachineName = "LemonMilkshake", acceptedItems = {"Glass of Milk"}, product = "Lemon Milkshake"},
["LimeMilkshake"] = {MachineName = "LimeMilkshake", acceptedItems = {"Glass of Milk"}, product = "Lime Milkshake"},
["OrangeMilkshake"] = {MachineName = "OrangeMilkshake", acceptedItems = {"Glass of Milk"}, product = "Orange Milkshake"},
["StrawberryMilkshake"] = {MachineName = "StrawberryMilkshake", acceptedItems = {"Glass of Milk"}, product = "Strawberry Milkshake"},
["Blender"] = {MachineName = "Blender", acceptedItems = {"Strawberry Milk", "Orange Milk", "Lemon Milk", "Lime Milk", "Blueberry Milk", "Banana Milk"}, product = "Strawberry Milkshake", "Orange Milkshake", "Lemon Milkshake", "Lime Milkshake", "Blueberry Milkshake", "Banana Milkshake"},
["Ice"] = {MachineName = "Ice", acceptedItems = {"Americano", "Cappucino", "Decaf", "Espresso", "Frappe", "Latte", "Macchiato", "Mocha", "Regular", "Americano w/Cream", "Cappucino w/Cream,", "Decaf w/Cream", "Espresso w/Cream", "Frappe w/Cream", "Latte w/Cream", "Macchiato w/Cream", "Mocha w/Cream", "Regular w/Cream", "Americano w/Sugar", "Cappucino w/Sugar", "Decaf w/Sugar", "Espresso w/Sugar", "Frappe w/Sugar", "Latte w/Sugar", "Macchiato w/Sugar", "Mocha w/Sugar", "Regular w/Sugar", "Americano w/Sugar & Cream", "Cappucino w/Sugar & Cream", "Decaf w/Sugar & Cream", "Espresso w/Sugar & Cream", "Frappe w/Sugar & Cream", "Latte w/Sugar & Cream", "Macchiato w/Sugar & Cream", "Mocha w/Sugar & Cream", "Regular w/Sugar & Cream"}, product = "Cup.Name"},
--["Cream"] = {MachineName = "Cream", acceptedItems = {"Americano", "Cappucino", "Decaf", "Espresso", "Frappe", "Latte", "Macchiato", "Mocha", "Regular", "Iced Americano, "Iced Cappucino", "Iced Decaf", "Iced Espresso", "Iced Frappe", "Iced Latte", "Iced Macchiato", "Iced Regular", "Americano w/ Sugar", "Cappucino w/Sugar", "Decaf w/Sugar", "Espresso w/Sugar", "Frappe w/Sugar", "Latte w/Sugar", "Macchiato w/Sugar", "Mocha w/Sugar", "Regular w/Sugar", "Iced Americano w/Sugar", "Iced Cappucino w/Sugar", "Iced Decaf w/Sugar", "Iced Espresso w/Sugar", "Iced Frappe w/Sugar", "Iced Latte w/ Sugar", "Iced Macchiato w/Sugar", " Iced Mocha w/Sugar", "Iced Regular w/Sugar"}, product = "Americano w/Cream", "Cappucino w/Cream", "Decaf w/Cream", "Espresso w/Cream", "Frappe w/ Cream", "Latte w/Cream", "Macchiato w/Cream", "Mocha w/Cream", "Regular w/Cream", "Iced Americano w/Cream", "Iced Cappucino w/Cream", "Iced Decaf w/Cream", "Iced Espresso w/Cream", "Iced Frappe w/Cream", "Iced Latte w/Cream", "Iced Macchiato w/Cream", "Iced Mocha w/Cream", "Iced Regular w/Cream", "Americano w/ Sugar & Cream", "Cappucino w/Sugar & Cream", "Decaf w/Sugar & Cream", "Espresso w/Sugar & Cream", "Frappe w/Sugar & Cream", "Latte w/Sugar & Cream", "Macchiato w/Sugar & Cream", "Mocha w/Sugar & Cream", "Regular w/Sugar & Cream", "Iced Americano w/Sugar & Cream", "Iced Cappucino w/Sugar & Cream", "Iced Decaf w/Sugar & Cream", "Iced Espresso w/Sugar & Cream", "Iced Frappe w/Sugar & Cream", "Iced Latte w/ Sugar & Cream", "Iced Macchiato w/Sugar & Cream", " Iced Mocha w/Sugar & Cream", "Iced Regular w/Sugar & Cream"},
["Sugar"] = {MachineName = "Sugar", acceptedItems = {"Americano", "Cappucino", "Decaf", "Espresso", "Frappe", "Latte", "Macchiato", "Mocha", "Regular", "Americano w/Cream", "Cappucino w/Cream,", "Decaf w/Cream", "Espresso w/Cream", "Frappe w/Cream", "Latte w/Cream", "Macchiato w/Cream", "Mocha w/Cream", "Regular w/Cream", "Iced Americano", "Iced Cappucino", "Iced Decaf", "Iced Espresso", "Iced Frappe", "Iced Latte", "Iced Macchiato", "Iced Mocha", "Iced Regular", "Iced Americano w/Cream", "Iced Cappucino w/Cream", "Iced Decaf w/Cream", "Iced Espresso w/Cream", "Iced Frappe w/Cream", "Iced Latte w/Cream", "Iced Macchiato w/Cream", "Iced Mocha w/Cream", "Iced Regular w/Cream"}, product = "cup.Name"},
}
for _,dispenser in pairs(directory:GetDescendants()) do
if dispenser:IsA("Part") and dispenser.Name == "Dispenser" then
dispenser.Touched:Connect(function(hit)
for _,valid in pairs(authorizedItems) do
if hit.Parent.Name == valid then
local cup = hit.Parent
for _,val in pairs(authorizedMachines) do
if dispenser.Parent.Name == val then
local AddOn = false
local machine = dispenser.Parent
local array = machineRequirements[machine.Name]
if machine.AddOn then
AddOn = true
end
for _,v in pairs(array.acceptedItems) do
if cup.Name == v then
cup.Name = array.product
end
end
end
end
end
end
end)
end
end
This is the code, I apologise for the table being incredibly messy. The last 2 lines have the “Cup.Name”.
I attempted using BoolValues with local AddOn, but it didn’t work, that’s why I’m resorting to this method.