Cooking Simulator

 👨‍🍳 Cooking Simulator — ідеальна проста гра для початківця в Roblox Studio, бо ти зможеш навчитися:

  • працювати з колекцією об’єктів (інгредієнти),

  • робити взаємодію (взяти предмет → покласти на стіл),

  • створювати UI для рецептів.

Я розпишу план покроково, щоб ти міг зробити перший прототип за 1 вечір.


🔧 1. Підготовка сцени

Створюємо локацію

  • Зроби невелику кухню:

    • Стіл (Part, Anchored = true).

    • Каструля (MeshPart або простий Part, щоб гравець кладе туди інгредієнти).

    • Інгредієнти: наприклад, Tomato, Cheese, Bread.


🖱 2. Збір інгредієнтів

Крок 1: додаємо ProximityPrompt

  1. На кожен інгредієнт встав ProximityPrompt:

    • ActionText = "Взяти"

    • ObjectText = "Помідор" (для кожного інгредієнта свій текст).

    • HoldDuration = 0 (щоб не треба було утримувати).

Крок 2: скрипт для збору інгредієнтів

Встав Script у кожен інгредієнт:

local prompt = script.Parent:WaitForChild("ProximityPrompt") local Players = game:GetService("Players") prompt.Triggered:Connect(function(player) -- Клонуємо інгредієнт як Tool і додаємо у Backpack local tool = Instance.new("Tool") tool.Name = script.Parent.Name tool.RequiresHandle = false tool.Parent = player.Backpack -- Прибираємо інгредієнт з карти script.Parent:Destroy() end)

Тепер гравець може "взяти" предмет і носити його як Tool.


🍲 3. Готування в каструлі

Крок 1: створюємо каструлю

  • Створи Part → назви Pot.

  • Додай TouchInterest (він з’явиться автоматично при використанні Touched).

Крок 2: скрипт у каструлі

Встав Script у Pot:

local pot = script.Parent local correctRecipe = {"Tomato", "Cheese"} -- Рецепт: Помідор + Сир local addedIngredients = {} pot.Touched:Connect(function(hit) local character = hit.Parent local player = game.Players:GetPlayerFromCharacter(character) if player then -- Перевіряємо, що гравець тримає Tool local tool = character:FindFirstChildOfClass("Tool") if tool then table.insert(addedIngredients, tool.Name) tool:Destroy() -- Видаляємо Tool з рук print("Додано інгредієнт:", tool.Name) -- Перевірка рецепту if #addedIngredients == #correctRecipe then local success = true for _, ingredient in ipairs(correctRecipe) do if not table.find(addedIngredients, ingredient) then success = false break end end if success then print("✅ Рецепт готовий! Вітаю!") pot.BrickColor = BrickColor.Green() -- Візуальний ефект else print("❌ Неправильний рецепт!") pot.BrickColor = BrickColor.Red() end addedIngredients = {} -- Очищаємо каструлю end end end end)

Тепер гравець може носити інгредієнти й кидати їх у каструлю — якщо рецепт правильний, каструля змінює колір на зелений.


🖼 4. UI для рецептів

1. ModuleScript з рецептами

У ReplicatedStorage → створіть ModuleScript з назвою Recipes:

local Recipes = { ["Burger"] = {"Bread", "Meat", "Cheese"}, ["Pizza"] = {"Dough", "Tomato", "Cheese"}, ["Salad"] = {"Lettuce", "Tomato", "Cucumber"}, } return Recipes

2. Серверний скрипт (в ServerScriptService)

Створіть RemoteEvent у ReplicatedStorage → назвіть NewOrder.

local ReplicatedStorage = game:GetService("ReplicatedStorage") local Players = game:GetService("Players") local Recipes = require(ReplicatedStorage:WaitForChild("Recipes")) local newOrderEvent = ReplicatedStorage:WaitForChild("NewOrder") function giveRandomOrder(player) local recipeNames = {} for name, _ in pairs(Recipes) do table.insert(recipeNames, name) end local randomRecipe = recipeNames[math.random(1, #recipeNames)] newOrderEvent:FireClient(player, randomRecipe, Recipes[randomRecipe]) end -- Видавати замовлення при вході в гру Players.PlayerAdded:Connect(function(player) task.wait(5) giveRandomOrder(player) -- Кожні 60 секунд нове замовлення while player.Parent do task.wait(60) giveRandomOrder(player) end end)

3. LocalScript у GUI

У StarterGui → створіть ScreenGui → TextLabel + Frame для відображення замовлення.
У LocalScript:

local ReplicatedStorage = game:GetService("ReplicatedStorage") local newOrderEvent = ReplicatedStorage:WaitForChild("NewOrder") local orderLabel = script.Parent:WaitForChild("OrderLabel") -- TextLabel local ingredientsFrame = script.Parent:WaitForChild("IngredientsFrame") -- Frame з текстами newOrderEvent.OnClientEvent:Connect(function(recipeName, ingredients) orderLabel.Text = "Новий рецепт: " .. recipeName for _, child in ipairs(ingredientsFrame:GetChildren()) do if child:IsA("TextLabel") then child:Destroy() end end for _, ingredient in ipairs(ingredients) do local label = Instance.new("TextLabel") label.Size = UDim2.new(1,0,0,20) label.Text = "- " .. ingredient label.Parent = ingredientsFrame end end)

Як завершити систему:

  • Додати перевірку страви: коли гравець приносить страву клієнту → сервер перевіряє чи інгредієнти збігаються з рецептом.

  • Додати винагороду: leaderstats.Cash.Value += 50.

  • Додати таймер на виконання замовлення.


Оновлені скрипти:

Крок 1: Скрипт у каструлі

-- Workspace.Pot.PotScript (Script)
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Recipes = require(ReplicatedStorage:WaitForChild("Recipes"))
local correctRecipe = {} -- зберігатимемо таблицю (масив інгредієнтів)

-- безпечний require, щоб побачити помилку, якщо модуль не той
local ok, OrderManager = pcall(function()
return require(game.ServerScriptService:WaitForChild("OrderManager"))
end)
if not ok then
warn("Не вдалося require OrderManager:", OrderManager)
return
end

-- Каструля
local pot = script.Parent
local addedIngredients = {}

-- Функція для оновлення правильного рецепта
local function updateRecipe(player)
local recipeName = OrderManager.GetRecipe(player)
if recipeName then
correctRecipe = Recipes[recipeName] -- ✅ тепер масив інгредієнтів
print("Рецепт:", recipeName)
print("Інгредієнти:", table.concat(correctRecipe, ", "))
else
correctRecipe = {}
end
end

-- Основна логіка
pot.Touched:Connect(function(hit)
local character = hit.Parent
local player = Players:GetPlayerFromCharacter(character)
if not player then return end

-- Оновлюємо рецепт для цього гравця
updateRecipe(player)

-- Перевіряємо, що гравець тримає Tool
local tool = character:FindFirstChildOfClass("Tool")
if tool then
table.insert(addedIngredients, tool.Name)
tool:Destroy() -- Видаляємо Tool з рук

print("Додано інгредієнт:", tool.Name)
print("Очікувано:", table.concat(correctRecipe, ", "))
print("Маємо:", table.concat(addedIngredients, ", "))

-- Перевірка рецепту
if #addedIngredients == #correctRecipe then
local success = true
for _, ingredient in ipairs(correctRecipe) do
if not table.find(addedIngredients, ingredient) then
success = false
break
end
end

if success then
print("✅ Рецепт готовий! Вітаю!")
pot.BrickColor = BrickColor.Green() -- Візуальний ефект
else
print("❌ Неправильний рецепт!")
pot.BrickColor = BrickColor.Red()
end
addedIngredients = {} -- Очищаємо каструлю
end
end
end)

Крок 2: Серверний скрипт

-- ServerScriptService > OrderSpawner (Script)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local OrderManager = require(game.ServerScriptService:WaitForChild("OrderManager"))

local newOrderEvent = ReplicatedStorage:WaitForChild("NewOrder")

Players.PlayerAdded:Connect(function(player)
task.wait(5)
local recipe = OrderManager.AssignRandomOrder(player)
newOrderEvent:FireClient(player, recipe, require(ReplicatedStorage:WaitForChild("Recipes"))[recipe])

while player.Parent do
task.wait(60)
local recipe = OrderManager.AssignRandomOrder(player)
newOrderEvent:FireClient(player, recipe, require(ReplicatedStorage:WaitForChild("Recipes"))[recipe])
end
end)

Крок 3: Серверний модульний скрипт (назвати OrderManager)

-- ServerScriptService > OrderManager (ModuleScript)
local OrderManager = {}
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Recipes = require(ReplicatedStorage:WaitForChild("Recipes"))

local activeOrders = {}

function OrderManager.AssignOrder(player, recipeName)
if player and recipeName then
activeOrders[player.UserId] = recipeName
end
end

function OrderManager.GetRecipe(player)
if not player then return nil end
return activeOrders[player.UserId]
end

function OrderManager.ClearOrder(player)
activeOrders[player.UserId] = nil
end

function OrderManager.AssignRandomOrder(player)
local names = {}
for name,_ in pairs(Recipes) do table.insert(names, name) end
local pick = names[math.random(1, #names)]
OrderManager.AssignOrder(player, pick)
return pick
end

Players.PlayerRemoving:Connect(function(player)
activeOrders[player.UserId] = nil
end)

return OrderManager