A cursed convenience store game sounds like a BLAST! I've got you covered with some copy-paste-friendly scripts. Since you're new to coding, I'll explain what each part does, so you can tweak them if needed. We'll use ROBLOX's Lua scripting language. Ready?
Before we start:
- Create a new ROBLOX game or open your existing one.
- Make sure you have the following in your Workspace:
- A
ConvenienceStore model (or whatever you want to name it) containing:
- Individual item models (e.g.,
Milk, Bread, Candy, etc.). These will be the collectibles.
- A
ShoppingListGUI ScreenGui (we'll create the script for this soon).
- A
Script (not LocalScript) inside ServerScriptService (we'll use this for event scripts).
- Familiarize yourself with the ROBLOX Explorer window (where you'll see all the objects in your game).
Now, let's get scripting!
Script 1: Shopping List GUI (LocalScript)
Create a new LocalScript inside the ShoppingListGUI ScreenGui. Name it ShoppingListScript. Paste this code:
-- ShoppingListScript (LocalScript)
-- Configuration
local shoppingList = {
"Milk",
"Bread",
"Candy",
"Newspaper",
"Soda"
}
-- GUI elements
local gui = script.Parent
local listFrame = gui:WaitForChild("ListFrame")
local itemTemplate = listFrame:WaitForChild("ItemTemplate")
-- Create shopping list items
for i, itemName in pairs(shoppingList) do
local itemLabel = itemTemplate:Clone()
itemLabel.Name = itemName
itemLabel.Text = itemName
itemLabel.Parent = listFrame
itemLabel.Visible = true
-- Store the item name in the label for later use
itemLabel.ItemName = itemName
end
-- Function to tick off an item
local function tickOffItem(itemName)
for _, child in pairs(listFrame:GetChildren()) do
if child:IsA("TextLabel") and child.ItemName == itemName then
child.Text = itemName .. " (FOUND!)"
child.TextColor3 = Color3.new(0, 1, 0) -- Green color
end
end
end
-- Listen for item collection events from the server
game.ReplicatedStorage:WaitForChild("ItemCollectedEvent").OnClientEvent:Connect(function(itemName)
tickOffItem(itemName)
end)
What this script does:
- Creates a shopping list GUI with items from the
shoppingList table.
- Clones a template label for each item and stores the item name in the label.
- Waits for the server to send an
ItemCollectedEvent (we'll create this event later).
- When an item is collected, it ticks off the corresponding label in the GUI.
Setup:
- Inside the
ShoppingListGUI ScreenGui, create a new Frame named ListFrame.
- Inside
ListFrame, create a new TextLabel named ItemTemplate. Set its Visible property to false. This will be the template for each shopping list item.
- Customize the GUI appearance as you like (fonts, colors, sizes, etc.).
Script 2: Item Collection Script (Script)
Create a new Script (not LocalScript) inside ServerScriptService. Name it ItemCollector. Paste this code:
-- ItemCollector (Script)
-- Configuration
local items = {
Milk = "Milk",
Bread = "Bread",
Candy = "Candy",
Newspaper = "Newspaper",
Soda = "Soda"
}
-- Event to notify clients about collected items
local itemCollectedEvent = Instance.new("RemoteEvent")
itemCollectedEvent.Name = "ItemCollectedEvent"
itemCollectedEvent.Parent = game.ReplicatedStorage
-- Function to handle item collection
local function collectItem(player, itemName)
-- Tick off the item in the client's GUI
itemCollectedEvent:FireClient(player, itemName)
-- Optional: You can add item-specific actions here (e.g., give player a reward)
print(player.Name .. " collected " .. itemName)
end
-- Connect to item models' Touched events
for itemName, labelName in pairs(items) do
local itemModel = game.Workspace.ConvenienceStore:FindFirstChild(itemName)
if itemModel then
itemModel.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
collectItem(player, labelName)
-- Optional: Destroy the item model after collection
-- itemModel:Destroy()
end
end)
else
warn("Item model not found: " .. itemName)
end
end
What this script does:
- Defines a table
items mapping item model names to their corresponding shopping list labels.
- Creates a
RemoteEvent to notify clients when an item is collected.
- When a player touches an item model, it fires the
ItemCollectedEvent to the client's GUI, ticking off the item.
- You can optionally add item-specific actions or destroy the item model after collection.
Setup:
- Make sure your item models (e.g.,
Milk, Bread, etc.) are direct children of the ConvenienceStore model in the Workspace.
- Update the
items table in the script to match your item model names.
Script 3: Event Scripts (Script)
Create another new Script (not LocalScript) inside ServerScriptService. Name it CursedEvents. Paste this code:
-- CursedEvents (Script)
-- Configuration
local eventChance = 0.2 -- 20% chance of an event happening when an item is collected
local events = {
{
name = "Flickering Lights",
chance = 0.5, -- 50% chance of this event happening if eventChance succeeds
action = function()
local lights = game.Workspace.ConvenienceStore:FindFirstChild("Lights")
if lights then
for i = 1, 10 do
lights.PointLight.Enabled = not lights.PointLight.Enabled
wait(0.1)
end
lights.PointLight.Enabled = true
end
end
},
{
name = "Sudden Wind",
chance = 0.3,
action = function()
local windSound = Instance.new("Sound")
windSound.SoundId = "rbxassetid://183766569" -- creepy wind sound
windSound.Parent = game.Workspace
windSound:Play()
wait(2)
windSound:Destroy()
for _, model in pairs(game.Workspace.ConvenienceStore:GetDescendants()) do
if model:IsA("BasePart") then
model.CFrame = model.CFrame * CFrame.new(math.random(-1, 1), 0, math.random(-1, 1))
end
end
end
},
{
name = "Mysterious Message",
chance = 0.2,
action = function(player)
local message = Instance.new("BillboardGui")
message.Size = UDim2.new(0, 200, 0, 50)
message.StudsOffset = Vector3.new(0, 2, 0)
message.Parent = player.Character.Head
local label = Instance.new("TextLabel")
label.Size = UDim2.new(1, 0, 1, 0)
label.Text = "THEY'RE WATCHING YOU"
label.TextSize = 24
label.TextColor3 = Color3.new(1, 0, 0)
label.BackgroundTransparency = 1
label.Parent = message
wait(3)
message:Destroy()
end
}
}
-- Listen for item collection events
game.ReplicatedStorage:WaitForChild("ItemCollectedEvent").OnServerEvent:Connect(function(player, itemName)
if math.random() < eventChance then
local event = events[math.random(1, #events)]
if math.random() < event.chance then
print("Event triggered:", event.name)
event.action(player) -- Pass player if the event needs it
end
end
end)
What this script does:
- Defines a table
events containing quirky, eerie events with their chances of happening.
- When an item is collected (detected via the
ItemCollectedEvent), there's a 20% chance (eventChance) of triggering an event.
- If an event is triggered, it randomly selects one from the
events table based on their individual chances.
- Each event has a custom
action function that executes the desired effect (e.g., flickering lights, sudden wind, mysterious message).
Setup:
- You can modify or add events in the
events table. Just follow the format:
name: Event description (for debugging).
chance: The probability of this event happening if eventChance succeeds.
action: A function containing the event's logic. You can use player as an argument if needed.
- For the "Flickering Lights" event, ensure you have a
Lights model with a PointLight inside your ConvenienceStore.
- For the "Sudden Wind" event, you can change the
SoundId to a different creepy sound asset ID.
That's it! You've now got the core scripts for your cursed convenience store game:
ShoppingListScript (LocalScript): Manages the shopping list GUI.
ItemCollector (Script): Handles item collection and notifies clients.
CursedEvents (Script): Triggers random, quirky events when items are collected.
Tips and Variations:
- To make events more player-specific, modify the
action functions in CursedEvents to use the player argument.
- Add more events, items, or GUI elements to increase variety and replayability.
- Experiment with different
eventChance values or event probabilities.
- Consider adding a " cursed meter" that fills up as events occur, leading to a final, intense event when full.
- If you want to make the game more challenging, add time limits or penalties for incomplete shopping lists.
Now, go forth and curse that convenience store! Have fun in the gamejam contest! If you need help or have questions, feel free to ask. Good luck, and happy game developing!