Start building

How to make a shop GUI in Roblox Studio (with a secure server check)

Design a shop window that looks right on every screen, then wire the Buy button to a server check so nobody can shop for free.

A Roblox character holding a golden sword just bought in the shop, with the message Golden Sword equipped.
On this page
  1. What you are building
  2. Build the window with Scale, not Offset
  3. Lay out the items with a UIGridLayout
  4. Define the items once in a ModuleScript
  5. Open and close the shop with TweenService
  6. Buy items with a RemoteFunction and a server check
  7. Make the shop work on phones
  8. Test it and keep building
  9. Questions

To make a shop GUI in Roblox, add a ScreenGui to StarterGui, build the window from a Frame, and fill a UIGridLayout with item cards that a LocalScript clones from one template. When a player presses Buy, the client asks the server through a RemoteFunction, and a server Script checks the price and the player's Coins before it hands anything over. This guide builds each piece, and the finished shop works on phones too.

What you are building

A Shop button on the left of the screen slides a window up from the bottom. Each card in it shows an item's name, its price and a Buy button. Buying takes Coins from the player's leaderstats, puts a Tool in their Backpack, and a status line says what happened.

You need a leaderstats folder with an IntValue named Coins (the leaderboard guide sets one up) and a few Tools to sell. Then create these objects. In the Explorer, hover over a parent, click its + button and pick the class:

  • StarterGui: a ScreenGui named ShopGui, holding:
    • OpenButton (TextButton)
    • ShopFrame (Frame) with Title (TextLabel), CloseButton (TextButton), Items (ScrollingFrame) and Status (TextLabel)
    • ShopToggle and ShopClient (LocalScripts)
  • ReplicatedStorage: ShopItems (ModuleScript) and BuyItem (RemoteFunction)
  • ServerStorage: a Folder named ShopTools with the Tools you sell
  • ServerScriptService: ShopServer (Script)

Build the window with Scale, not Offset

Every Size and Position in Roblox UI is a UDim2, which Studio shows as {X Scale, X Offset},{Y Scale, Y Offset}. Scale is a fraction of the parent, so 0.5 means half. Offset is pixels. A frame sized {0, 400},{0, 300} is 400 by 300 pixels on every screen: huge on a phone, small on a large monitor. Sized {0.6, 0},{0.7, 0}, it always covers 60% of the width and 70% of the height. In a script those are UDim2.fromOffset(400, 300) and UDim2.fromScale(0.6, 0.7).

The rule of thumb: use Scale for sizes and positions, and Offset only where a fixed size is the point, such as padding, outlines and thumb-sized buttons. AnchorPoint picks which point of an object sits at its Position, so 0.5, 0.5 centers it.

Select each object and set these in Properties:

ObjectAnchorPointPositionSize
ShopFrame0.5, 0.5{0.5, 0},{0.5, 0}{0.6, 0},{0.7, 0}
Title0, 0{0, 0},{0, 0}{0.7, 0},{0.15, 0}
CloseButton1, 0{1, 0},{0, 0}{0, 44},{0, 44}
Items0, 0{0, 0},{0.2, 0}{1, 0},{0.66, 0}
Status0, 1{0, 0},{1, 0}{1, 0},{0.1, 0}
OpenButton0, 0.5{0, 16},{0.4, 0}{0, 120},{0, 50}

Next, insert three objects into ShopFrame to style it:

  1. UICorner with CornerRadius 0, 16 rounds the corners.
  2. UIStroke with Thickness 3 and a lighter color draws an outline. On a Frame it traces the edge. On a TextLabel or TextButton it outlines the text instead, unless you set its ApplyStrokeMode to Border.
  3. UIPadding with 0, 12 on all four sides keeps the contents off the edge. Scale values inside ShopFrame now measure the padded area.

Give OpenButton and CloseButton a UICorner too, set the Text of Title and OpenButton to Shop, and set CloseButton's to X. If your game already has a look, you can ask Revix to restyle the shop to match it.

Lay out the items with a UIGridLayout

A UIGridLayout sizes and places every card for you, in neat rows.

  1. Select Items. Set BackgroundTransparency to 1, CanvasSize to {0, 0},{0, 0} and AutomaticCanvasSize to Y, so the scroll area grows as cards are added.
  2. Insert a UIGridLayout into Items. Set CellSize to {0.31, 0},{0, 150}, CellPadding to {0.02, 0},{0, 10} and SortOrder to LayoutOrder. Scale on the width fits three cards per row on any screen. Offset on the height keeps every card tall enough to read.
  3. Insert a Frame named ItemTemplate into Items and give it a UICorner. Inside it, add a TextLabel named ItemName at the top, a TextLabel named Price below it and a TextButton named BuyButton along the bottom. Size these with Scale so they follow the card.

Style this one card until you like it. When the game runs, the script takes the original out of the grid and stamps out one copy per item, so keep those three names exactly as written.

Define the items once in a ModuleScript

Both sides need the item list: the client to draw the cards, the server to check prices. Keep it in one ModuleScript in ReplicatedStorage, and changing a price becomes a one-line edit.

ModuleScriptReplicatedStorage
-- ModuleScript named ShopItems in ReplicatedStorage: everything the shop sells, defined once
local ShopItems = {}

-- Tool must match the name of a Tool inside ServerStorage > ShopTools
ShopItems.List = {
	{ Name = "Wooden Sword", Price = 50, Tool = "WoodenSword" },
	{ Name = "Speed Coil", Price = 150, Tool = "SpeedCoil" },
	{ Name = "Grapple Hook", Price = 400, Tool = "GrappleHook" },
}

function ShopItems.Get(name)
	for _, item in ipairs(ShopItems.List) do
		if item.Name == name then
			return item
		end
	end
	return nil
end

return ShopItems

Cards appear in list order, and Get finds an item by name. The Tools sit in ServerStorage because nothing there reaches the client. And since the server requires its own copy of this module, an exploiter who edits the copy on their computer changes nothing the server reads.

Open and close the shop with TweenService

The window waits below the screen and slides up when the player presses Shop. TweenService animates the Position for you.

LocalScriptShopGui
-- LocalScript named ShopToggle inside ShopGui: slides the shop window in and out
local TweenService = game:GetService("TweenService")

local gui = script.Parent
local shopFrame = gui:WaitForChild("ShopFrame")
local openButton = gui:WaitForChild("OpenButton")
local closeButton = shopFrame:WaitForChild("CloseButton")

local OPEN_POSITION = UDim2.fromScale(0.5, 0.5)
local CLOSED_POSITION = UDim2.fromScale(0.5, 1.5) -- parked below the screen
local slide = TweenInfo.new(0.35, Enum.EasingStyle.Back, Enum.EasingDirection.Out)

local isOpen = false
shopFrame.Position = CLOSED_POSITION

local function setOpen(open)
	isOpen = open
	local goal = if open then OPEN_POSITION else CLOSED_POSITION
	TweenService:Create(shopFrame, slide, { Position = goal }):Play()
end

openButton.Activated:Connect(function()
	setOpen(not isOpen)
end)

closeButton.Activated:Connect(function()
	setOpen(false)
end)

When the game starts, the script parks ShopFrame below the screen, so you can leave it centered while you design. Each press tweens from wherever the frame is to the new goal, and a new tween on the same property replaces the old one, so pressing Shop mid-slide just turns it around. Back easing overshoots slightly, which reads as a small bounce. Quad is calmer.

Buy items with a RemoteFunction and a server check

A RemoteFunction is like a RemoteEvent that waits for a reply. The client calls InvokeServer with the item's name, the server runs its OnServerInvoke function, and whatever that returns comes back to the client. That suits a shop: the player sees "You bought Speed Coil!" or "You need 30 more Coins" right away.

The server Script

ScriptServerScriptService
-- Script named ShopServer in ServerScriptService: the only place a purchase is decided
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")

local ShopItems = require(ReplicatedStorage:WaitForChild("ShopItems"))
local buyItem = ReplicatedStorage:WaitForChild("BuyItem")
local shopTools = ServerStorage:WaitForChild("ShopTools")

buyItem.OnServerInvoke = function(player, itemName)
	-- The client only names an item. Everything else is decided here.
	if typeof(itemName) ~= "string" then
		return false, "Unknown item"
	end
	local item = ShopItems.Get(itemName)
	if not item then
		return false, "Unknown item"
	end

	local tool = shopTools:FindFirstChild(item.Tool)
	if not tool then
		warn("ShopTools has no Tool named " .. item.Tool)
		return false, "Out of stock"
	end

	local leaderstats = player:FindFirstChild("leaderstats")
	local coins = leaderstats and leaderstats:FindFirstChild("Coins")
	local backpack = player:FindFirstChildOfClass("Backpack")
	local starterGear = player:FindFirstChild("StarterGear")
	if not (coins and backpack and starterGear) then
		return false, "Still loading, try again"
	end

	if starterGear:FindFirstChild(item.Tool) then
		return false, "You already own " .. item.Name
	end
	if coins.Value < item.Price then
		return false, "You need " .. (item.Price - coins.Value) .. " more Coins"
	end

	coins.Value -= item.Price
	tool:Clone().Parent = backpack
	tool:Clone().Parent = starterGear
	return true, "You bought " .. item.Name .. "!"
end

Roblox passes the real player as the first argument, and that can't be faked. Everything after it is untrusted, so the script checks that itemName is a string and looks the item up in the server's own list. Only after confirming the player has Coins, doesn't own the Tool yet and can afford it does it take the Coins and clone the Tool twice: into the Backpack to use now, and into StarterGear so it returns after every respawn. Nothing between the checks and the subtraction waits, so a double click can't spend the same Coins twice.

The client LocalScript

LocalScriptShopGui
-- LocalScript named ShopClient inside ShopGui: makes one card per item and sends Buy requests
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local ShopItems = require(ReplicatedStorage:WaitForChild("ShopItems"))
local buyItem = ReplicatedStorage:WaitForChild("BuyItem")

local shopFrame = script.Parent:WaitForChild("ShopFrame")
local itemsFrame = shopFrame:WaitForChild("Items")
local status = shopFrame:WaitForChild("Status")
local template = itemsFrame:WaitForChild("ItemTemplate")
template.Parent = nil -- keep the original as a stamp, out of the grid

local GREEN = Color3.fromRGB(110, 230, 140)
local RED = Color3.fromRGB(255, 120, 120)
local busy = false

local function buy(item)
	if busy then
		return
	end
	busy = true
	status.Text = "Buying..."
	local ok, bought, message = pcall(function()
		return buyItem:InvokeServer(item.Name)
	end)
	if ok then
		status.Text = message
		status.TextColor3 = if bought then GREEN else RED
	else
		status.Text = "The shop didn't answer, try again"
		status.TextColor3 = RED
	end
	busy = false
end

for index, item in ipairs(ShopItems.List) do
	local card = template:Clone()
	card.Name = item.Tool
	card.LayoutOrder = index
	card.ItemName.Text = item.Name
	card.Price.Text = item.Price .. " Coins"
	card.BuyButton.Activated:Connect(function()
		buy(item)
	end)
	card.Parent = itemsFrame
end

Each card gets the item's place in the list as its LayoutOrder, so the grid keeps your order. The busy flag ignores extra taps while a request is on its way. The pcall matters too: InvokeServer throws an error if the server's function errors, and without it busy would stay true and the shop would stop answering.

Make the shop work on phones

Many Roblox players are on phones, so check four things before you publish:

  1. Keep the shape. Insert a UIAspectRatioConstraint into ShopFrame with AspectRatio 1.6. The window still fits inside its Scale size but keeps its proportions on tall and ultrawide screens.
  2. Scale text, with a cap. Turn on TextScaled for every label and button so the text fills its box. Then insert a UITextSizeConstraint into each one with MaxTextSize around 32, so a large monitor doesn't get giant letters, and a MinTextSize so it stays readable.
  3. Make tap targets big. Aim for at least 44 pixels on a button's short side. That's why OpenButton and CloseButton use Offset sizes, and why BuyButton takes a third of a 150 pixel card. If you size a button with Scale, add a UISizeConstraint with MinSize 90, 44 so it never shrinks below thumb size.
  4. Stay clear of the controls. Phones show a thumbstick at the bottom left and a jump button at the bottom right. Keep Shop on the left edge above the middle, and leave a gap between cards so a tap doesn't hit the neighbor.

The scripts use Activated rather than MouseButton1Click because it fires for clicks and taps alike. Studio's device emulator previews common phone sizes.

Test it and keep building

Press Play and run through this list:

  1. Open and close the shop, including mid-slide.
  2. Try to buy with too few Coins, then with enough. The Tool should appear in your Backpack and come back after you reset your character.
  3. Try to buy the same item twice.
  4. Watch the Output window for warnings, such as a Tool missing from ShopTools.

Next, give players reasons to earn and spend: daily rewards with streaks hand out Coins that bring people back to the shop. To sell items for Robux too, the guide to making money from your game covers game passes and developer products with secure server code. And since bought Tools are gone when the player leaves, save owned items in a DataStore and give them back on join.

If you'd rather skip the clicking, ask Revix to build the shop in your place: it creates the GUI, writes the scripts, runs a playtest and fixes what breaks.

Questions

How do I make a shop GUI in Roblox Studio?

Put a ScreenGui in StarterGui with a Frame for the window and a ScrollingFrame with a UIGridLayout for the items. A LocalScript clones one item card per entry in a ModuleScript, and the Buy button calls a RemoteFunction so a server Script can check the price and the player's Coins.

Why does my Roblox GUI look wrong on mobile?

Usually because sizes use Offset, which is fixed pixels, instead of Scale, which is a fraction of the parent. Switch Size and Position to Scale, add a UIAspectRatioConstraint to keep the window's shape, and use TextScaled with a UITextSizeConstraint so text fits.

Can exploiters buy items for free in my Roblox shop?

Only if the client decides the purchase. If the server reads the price from its own copy of the item list, checks the player's Coins and gives the Tool itself, a hacked client can only ask to buy, not cheat.

Should a shop use a RemoteEvent or a RemoteFunction?

Either works as long as the server makes every decision. A RemoteFunction is handy because it returns a result, so the client can show a success or error message without a second remote.

How do I sell shop items for Robux instead of Coins?

Create game passes or developer products in the Creator Hub and open Roblox's purchase prompt with MarketplaceService. Your server then grants the item, either after the pass purchase finishes or inside ProcessReceipt for developer products.

Your game is
one sentence away.

Start building free

Free to start. No card needed.