This guide shows you how to build a functional shop in Roblox Studio—a place where players can buy items with in-game currency. You’ll learn to create a shop GUI (graphical user interface), connect it to a leaderboard currency, and make purchases actually work. By the end, you’ll have a reusable shop system you can drop into any game. No scripting experience is required, but you should be comfortable navigating Roblox Studio’s basic interface.
What You’ll Need
- Roblox Studio installed (free from the Roblox website)
- A basic Roblox game project (you can use the default Baseplate template)
- Basic familiarity with the Explorer and Properties panels
- Patience—scripting is the most complex part
Step-by-Step
- Open your game in Roblox Studio. Launch Studio, click New, and choose a template like Baseplate. Save your place file before you start.
- Create a leaderboard for currency. In the Explorer panel, find the ServerScriptService. Right-click it, select Insert Object, and choose Script. Name it “CurrencyManager”. Double-click to open the script editor and paste this code:
-- Creates a leaderboard with a "Cash" value for every player local Players = game:GetService("Players") Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local cash = Instance.new("IntValue") cash.Name = "Cash" cash.Value = 100 -- starting money cash.Parent = leaderstats end)This script runs on the server and gives each player 100 Cash when they join. You can change the starting amount.
- Create a shop GUI. In the Explorer, expand StarterGui (or right-click StarterGui and Insert Object → ScreenGui). Insert a ScreenGui into StarterGui. Name it “ShopGUI”. Inside it, create a Frame (right-click ShopGUI → Insert Object → Frame). Set the Frame’s Size to something like {0.3, 0, 0.5, 0} and Position to {0.35, 0, 0.25, 0} using the Properties panel. Set its BackgroundColor3 to a dark gray.
- Add a title and close button. Inside the Frame, add a TextLabel for the title (e.g., “Shop”) and a TextButton for closing. Set the button’s Text to “X” and its Size to {0.1, 0, 0.1, 0}. Position it at the top-right corner of the frame.
- Create item buttons. For each item you want to sell, add a TextButton inside the Frame. For this example, we’ll make one item: a “Sword” that costs 50 Cash. Set the button’s Text to “Sword – 50 Cash”. Set its Size to {0.8, 0, 0.2, 0} and Position to {0.1, 0, 0.2, 0}. You can duplicate this button for more items.
- Add a purchase feedback label. Add another TextLabel inside the Frame. Set its Text to “” (empty) and its Position below the buttons. This will show messages like “Purchased!” or “Not enough cash!”.
- Write the purchase script. Inside the ShopGUI, add a LocalScript (right-click ShopGUI → Insert Object → LocalScript). Name it “ShopLogic”. Open it and paste the following code:
-- LocalScript inside ShopGUI local Players = game:GetService("Players") local player = Players.LocalPlayer local shopFrame = script.Parent.Frame local feedbackLabel = shopFrame.FeedbackLabel -- rename your label to FeedbackLabel local closeButton = shopFrame.CloseButton -- rename your button to CloseButton -- Hide the shop by default shopFrame.Visible = false -- Function to open/close closeButton.MouseButton1Click:Connect(function() shopFrame.Visible = false end) -- Example purchase for the Sword button local swordButton = shopFrame.SwordButton -- rename your button to SwordButton swordButton.MouseButton1Click:Connect(function() local leaderstats = player:FindFirstChild("leaderstats") local cash = leaderstats and leaderstats:FindFirstChild("Cash") if cash and cash.Value >= 50 then cash.Value = cash.Value - 50 -- Give the item (replace with your actual item giving code) local tool = Instance.new("Tool") tool.Name = "Sword" tool.Parent = player.Backpack feedbackLabel.Text = "Purchased Sword!" else feedbackLabel.Text = "Not enough cash!" end end) -- Optional: open shop with a key press (e.g., B) local UserInputService = game:GetService("UserInputService") UserInputService.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.B then shopFrame.Visible = not shopFrame.Visible end end)Important: Rename your GUI elements to match the script—set the Frame’s Name to “Frame”, the close button’s Name to “CloseButton”, the feedback label’s Name to “FeedbackLabel”, and the item button’s Name to “SwordButton”. If you don’t, the script won’t find them.
- Test your shop. Click the Play button in the toolbar. Your character should spawn. Press B to toggle the shop. Click the Sword button. If you have enough cash, you’ll see the purchase message and a Sword in your backpack. If not, you’ll see the error message.
- Add more items. Duplicate the SwordButton, rename it, adjust the price and item in the script, and update the button’s Text. Repeat for as many items as you want.
Common Mistakes
- Scripts in the wrong place: The currency script must be in ServerScriptService, not in StarterGui. The LocalScript must be inside the ScreenGui in StarterGui. If they’re swapped, nothing works.
- Names don’t match: The script references “Frame”, “CloseButton”, etc. If you rename them differently, the script errors. Always match the names exactly.
- Forgetting to hide the shop: If you don’t set the Frame’s Visible to false, the shop appears on screen all the time. The script does this, but if you remove that line, it stays visible.
- Using a Script instead of a LocalScript for the GUI: GUI interactions should be handled by LocalScripts. Server Scripts can’t directly respond to button clicks on the client.
- Not testing with a second player: The leaderstats only appear when a player joins. If you test solo, you’ll see it, but if you’re testing in a team test, make sure each player has their own cash.
Tips
- Use a ModuleScript for item data: Instead of hardcoding each item in the LocalScript, create a ModuleScript that lists all items, their prices, and what they give. This makes adding items much easier and keeps your code clean.
- Make the shop toggleable with a key: The script uses B. You can change it to any key. Make sure to tell players in the game description.
- Add a tooltip: When hovering over an item, show a description. You can use a TextLabel that changes text on MouseEnter and MouseLeave.
- Use a RemoteEvent for secure purchases: For serious games, don’t give items directly in the LocalScript. Instead, use a RemoteEvent to ask the server to validate the purchase. This prevents cheating.
- Animate the shop: Use TweenService to slide the frame in and out instead of just toggling visibility. It looks more professional.
Troubleshooting
- Shop doesn’t open when pressing B: Make sure the LocalScript is inside the ScreenGui, not in a child frame. Also check that the key code is correct. If you’re on a laptop, some keys might be intercepted by the OS.
- Button click does nothing: Check the Output window (View → Output) for script errors. Common issues: the button’s Name doesn’t match the script, or the script is a Server Script instead of a LocalScript.
- Cash doesn’t decrease: The currency script runs on the server. If you’re modifying cash from a LocalScript, it won’t replicate to the server. Make sure your purchase script is using the same leaderstats folder. If you’re using a RemoteEvent, ensure the server script handles the deduction.
- Item doesn’t appear in backpack: In Roblox, tools added to the Backpack are only visible to the player if they are replicated. If you’re adding the tool from a LocalScript, it won’t work. You must add the tool on the server. Use a RemoteEvent to tell the server to give the item.
- Shop is visible on spawn: The script sets shopFrame.Visible = false, but if you have multiple GUIs or the script fails to run, it may stay visible. Check that the script is enabled and that no other script is setting it to true.
Frequently Asked Questions
- Can I sell game passes or developer products in a shop? Yes, but those require different APIs (MarketplaceService). This guide covers in-game currency only. For game passes, you’d use a prompt to purchase with Robux.
- How do I make the shop open when a player touches a part? Replace the key press with a Touched event on a part. In the LocalScript, you can detect when the player’s character touches a specific part, then toggle the shop.
- Can I sell items that are not tools? Absolutely. You can give players coins, badges, or any other value. Just modify the script to set a value or unlock something.
- How do I save purchases between sessions? Use DataStoreService to save the player’s cash and owned items. This is more advanced. You’ll need a server script that loads data on join and saves on leave.
- Why is my shop only visible to me and not other players? If you put the GUI in StarterGui, it should be visible to all players. But if you put it in a PlayerGui directly (like in a script), it’s only for that player. Make sure it’s in StarterGui.
- Can I use this shop in a multiplayer game? Yes, it works in multiplayer. Each player has their own cash and their own GUI. However, for security, you should use RemoteEvents to handle purchases on the server.