This guide walks you through building a simple but functional shop GUI in Roblox Studio. You’ll create a clickable button that opens a shop interface, displays items with prices, lets players buy them with in-game currency, and gives them the item. No scripting experience beyond copying and pasting is required, but you should know your way around the Studio interface.
What You’ll Need
- Roblox Studio (free, available at create.roblox.com)
- A place to test (a basic Baseplate template is fine)
- Basic knowledge of the Explorer and Properties panels
- A few items you want to sell (you can use simple parts like a sword or a coin)
Step-by-Step
- Create a GUI folder and ScreenGui. In the Explorer, right-click on StarterGui and select Insert Object > ScreenGui. Name it ShopGUI. This will appear on the player’s screen when they join.
- Add a button to open the shop. Inside the ScreenGui, create a TextButton (right-click > Insert Object > TextButton). Name it OpenButton. Set its Text to “Open Shop” in the Properties panel. Resize it by dragging the handles or setting the Size property (e.g., X=0.2, Y=0.1). Position it near the bottom-left (set Position to X=0.05, Y=0.85).
- Create the shop frame. Inside the ScreenGui, add a Frame (Insert Object > Frame). Name it ShopFrame. Set its Size to something like X=0.5, Y=0.6 and Position to X=0.25, Y=0.2. Set BackgroundColor3 to a dark gray (e.g., RGB 50,50,50) for contrast. This will be the main shop window.
- Add a title and close button. Inside ShopFrame, add a TextLabel named Title with Text “Shop”. Stretch it across the top (Size X=1, Y=0.1). Add a TextButton named CloseButton with Text “X”. Place it in the top-right corner (Position X=0.9, Y=0.02, Size X=0.08, Y=0.08).
- Create item slots. Inside ShopFrame, add a ScrollingFrame (Insert Object > ScrollingFrame). Name it ItemList. Set its Size to X=1, Y=0.8 and Position to X=0, Y=0.1. This will hold the items and scroll if you have many. Set CanvasSize to a large value like X=0, Y=1000 (you’ll adjust it later).
- Design one item template. Inside ItemList, create a Frame named ItemTemplate. Set its Size to X=0.9, Y=0.15 and Position to X=0.05, Y=0.05. Inside this frame, add:
- A TextLabel named ItemName (Size X=0.4, Y=1, Text “Sword”)
- A TextLabel named ItemPrice (Size X=0.2, Y=1, Position X=0.5, Text “10 Coins”)
- A TextButton named BuyButton (Size X=0.2, Y=0.8, Position X=0.75, Y=0.1, Text “Buy”)
- Duplicate the template for each item. Right-click ItemTemplate and select Duplicate (or press Ctrl+D). Move the copy down by changing its Position Y to 0.25 (or use the move tool). Repeat for as many items as you want. Update the text in each copy’s ItemName and ItemPrice. Keep the template frame itself for reference, but you can delete it after duplication if you want.
- Set up the shop’s visibility. Select ShopFrame and set its Visible property to false (uncheck it) so the shop is hidden when the game starts. The OpenButton remains visible.
- Add a script to control the GUI. In the Explorer, right-click on ShopGUI and select Insert Object > LocalScript. Name it ShopScript. This script will handle opening/closing and buying. Double-click to open the code editor.
- Write the script. Paste the following code into the script:
local screenGui = script.Parent local shopFrame = screenGui:WaitForChild("ShopFrame") local openButton = screenGui:WaitForChild("OpenButton") local closeButton = shopFrame:WaitForChild("CloseButton") -- Open shop openButton.MouseButton1Click:Connect(function() shopFrame.Visible = true openButton.Visible = false end) -- Close shop closeButton.MouseButton1Click:Connect(function() shopFrame.Visible = false openButton.Visible = true end) -- Buy buttons for _, itemFrame in ipairs(shopFrame:WaitForChild("ItemList"):GetChildren()) do if itemFrame:IsA("Frame") and itemFrame:FindFirstChild("BuyButton") then local buyButton = itemFrame.BuyButton buyButton.MouseButton1Click:Connect(function() local price = tonumber(itemFrame.ItemPrice.Text:match("%d+")) local leaderstats = game.Players.LocalPlayer:FindFirstChild("leaderstats") if leaderstats and leaderstats:FindFirstChild("Coins") then local coins = leaderstats.Coins if coins.Value >= price then coins.Value = coins.Value - price -- Give item (example: give a tool) local tool = game.ServerStorage:FindFirstChild("Sword") if tool then local clone = tool:Clone() clone.Parent = game.Players.LocalPlayer.Backpack end -- Optional: show a confirmation message print("Item purchased!") else print("Not enough coins!") end else print("No leaderstats found") end end) end endNote: This script assumes you have a leaderstats folder with a Coins IntValue, and a Sword tool in ServerStorage. You’ll need to create those.
- Create the leaderstats (currency). In the Explorer, right-click on ServerScriptService and insert a Script (not LocalScript). Name it CurrencyScript. Paste this code:
game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local coins = Instance.new("IntValue") coins.Name = "Coins" coins.Value = 100 -- starting amount coins.Parent = leaderstats end) - Add a test item to sell. In the Explorer, right-click on ServerStorage and insert a Tool (e.g., a Sword). Name it “Sword”. You can add a MeshPart or just leave it as a basic tool. This is what the player gets when they buy.
- Test the game. Click the Play button (the green triangle) in the toolbar. Your character should spawn. Click “Open Shop” – the shop frame should appear. Click the Buy button – your Coins should decrease and the Sword should appear in your backpack (press B to open backpack).
Common Mistakes
- Forgetting to set ShopFrame.Visible to false. If you leave it true, the shop will be open from the start.
- Using a Script instead of a LocalScript for the GUI. LocalScripts are required for client-side GUI interactions. A regular Script won’t work for button clicks.
- Not creating the leaderstats folder. The buy script checks for leaderstats.Coins. If they don’t exist, it prints an error and nothing happens.
- Misnaming objects. The script uses specific names like “ShopFrame”, “ItemList”, “BuyButton”. If you rename them, the script will fail. Double-check names.
- Buying buttons not working because the loop runs before items are loaded. The script uses WaitForChild, but if you add items later, they won’t be connected. Make sure all item frames exist before testing.
Tips
- Use a module script for item data. Instead of hardcoding prices in the GUI, create a ModuleScript that stores item names, prices, and tool references. This makes adding items easier.
- Add a confirmation dialog. Before completing a purchase, show a second frame asking “Are you sure?” to prevent accidental clicks.
- Improve visuals. Use UI Corner, UI Stroke, and UI Gradient effects to make the shop look polished.
- Make the shop accessible from a key press. Instead of a button, you can also open the shop by pressing a key (e.g., B) using UserInputService.
- Test with multiple players. Use the “Play” drop-down and select “Start Server” to test with a second client to ensure the shop works for all players.
Troubleshooting
- Shop doesn’t open when clicking the button. Check that the LocalScript is inside ShopGUI and that the names match. Open the Output window (View > Output) to see any script errors.
- Buy button does nothing. Ensure the item frames are direct children of ItemList. If you have nested frames, the script’s loop might skip them. Also verify that the price text is a number (e.g., “10 Coins” – the script uses match(“%d+”) to extract the number).
- Error: “leaderstats not found”. Make sure the CurrencyScript is in ServerScriptService and that it runs before any player joins. Also check that the player’s leaderstats folder is named exactly “leaderstats” (lowercase).
- Item doesn’t appear in backpack. The script looks for a tool named “Sword” in ServerStorage. If you named it differently, change the name in the script. Also ensure the tool is not a LocalScript-only item.
- Shop frame appears but is cut off. Adjust the ScrollingFrame’s CanvasSize to be larger (e.g., Y=500) and set ScrollingEnabled to true. Also make sure the frame’s size is appropriate for your screen.
Frequently Asked Questions
- Can I sell gamepasses or developer products in the shop? Yes, but that requires using MarketplaceService and handling purchases server-side. This guide covers in-game currency only.
- How do I make the shop open for only one player? The ScreenGui is in StarterGui, so it’s given to every player. To make it exclusive, you can clone it only for certain players via a script.
- Why does the shop close when I die? By default, ScreenGuis in StarterGui are re-created on respawn. To keep the shop open, move the ScreenGui to the player’s PlayerGui and reset it manually.
- Can I use RemoteEvents to handle purchases server-side? Absolutely. For security, it’s recommended to validate purchases on the server using RemoteEvents instead of trusting the client.
- How do I add more items without rewriting the script? Your script loops through all frames in ItemList, so you can just duplicate an existing item frame and change its text. The script will automatically pick it up.
- Is it possible to sell tools that are already in the player’s inventory? Yes, you can check if the player already has the tool and prevent duplicate purchases, or allow multiple copies.
How to Make a Shop GUI in Roblox Studio