👨🍳 Cooking Simulator — ідеальна проста гра для початківця в Roblox Studio, бо ти зможеш навчитися:
-
працювати з колекцією об’єктів (інгредієнти),
-
робити взаємодію (взяти предмет → покласти на стіл),
-
створювати UI для рецептів.
Я розпишу план покроково, щоб ти міг зробити перший прототип за 1 вечір.
🔧 1. Підготовка сцени
Створюємо локацію
-
Зроби невелику кухню:
-
Стіл (Part, Anchored = true).
-
Каструля (MeshPart або простий Part, щоб гравець кладе туди інгредієнти).
-
Інгредієнти: наприклад, Tomato, Cheese, Bread.
🖱 2. Збір інгредієнтів
Крок 1: додаємо ProximityPrompt
-
На кожен інгредієнт встав ProximityPrompt:
Крок 2: скрипт для збору інгредієнтів
Встав Script у кожен інгредієнт:
Тепер гравець може "взяти" предмет і носити його як Tool.
🍲 3. Готування в каструлі
Крок 1: створюємо каструлю
Крок 2: скрипт у каструлі
Встав Script у Pot:
Тепер гравець може носити інгредієнти й кидати їх у каструлю — якщо рецепт правильний, каструля змінює колір на зелений.
🖼 4. UI для рецептів
1. ModuleScript з рецептами
У ReplicatedStorage → створіть ModuleScript з назвою Recipes:
2. Серверний скрипт (в ServerScriptService)
Створіть RemoteEvent у ReplicatedStorage → назвіть NewOrder.
3. LocalScript у GUI
У StarterGui → створіть ScreenGui → TextLabel + Frame для відображення замовлення.
У LocalScript:
Як завершити систему:
-
Додати перевірку страви: коли гравець приносить страву клієнту → сервер перевіряє чи інгредієнти збігаються з рецептом.
-
Додати винагороду: 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