Untitled
unknown
plain_text
9 months ago
5.4 kB
13
Indexable
--]]
------ CONFIG ------
local ITEMS = {
-- name price decal id gear id
{n="Grass Block", p=25, img=60788541, gear=18445653},
{n="Stone Block", p=50, img=60788565, gear=18445654},
{n="Wood Planks", p=75, img=60788593, gear=18445655},
{n="Glass Block", p=100, img=60788521, gear=18445656},
{n="TNT Block", p=500, img=60788611, gear=18445657},
}
--------------------
local ts = game:GetService("TweenService")
-- colours
local tan = Color3.fromRGB(210, 180, 140)
local darkTan = Color3.fromRGB(190, 160, 120)
local outline = Color3.fromRGB(150, 120, 80)
-- main container
local shop = Instance.new("ScreenGui")
shop.Name = "ShopGui"
shop.ResetOnSpawn = false
-- holder that moves (WIDER)
local holder = Instance.new("Frame")
holder.Size = UDim2.new(0, 600, 0, 400)
holder.Position = UDim2.new(0, -600, 0.5, -200) -- starts closed
holder.BackgroundTransparency = 0.5
holder.BackgroundColor3 = tan
holder.BorderSizePixel = 0
holder.Parent = shop
local outlineH = Instance.new("UIStroke")
outlineH.Color = outline
outlineH.Thickness = 2
outlineH.Parent = holder
-- tab attached to holder
local tab = Instance.new("TextButton")
tab.Size = UDim2.new(0, 30, 0, 80)
tab.Position = UDim2.new(1, 0, 0.5, -40)
tab.AnchorPoint = Vector2.new(0, 0.5)
tab.BackgroundColor3 = darkTan
tab.BorderSizePixel = 0
tab.Text = ">"
tab.TextColor3 = Color3.new(1, 1, 1)
tab.TextScaled = true
tab.Font = Enum.Font.SourceSansBold
tab.Parent = holder
-- visible tab outline
local outlineT = Instance.new("UIStroke")
outlineT.Color = Color3.fromRGB(100, 75, 55) -- darker brown
outlineT.Thickness = 3 -- thicker
outlineT.Parent = tab
-- top bar
local top = Instance.new("Frame")
top.Size = UDim2.new(1, 0, 0, 40)
top.Position = UDim2.new(0, 0, 0, 0)
top.BackgroundColor3 = darkTan
top.BorderSizePixel = 0
top.Parent = holder
local topOutline = Instance.new("UIStroke")
topOutline.Color = outline
topOutline.Thickness = 2
topOutline.Parent = top
local topLbl = Instance.new("TextLabel")
topLbl.Size = UDim2.new(1, 0, 1, 0)
topLbl.BackgroundTransparency = 1
topLbl.Text = "SHOP"
topLbl.TextColor3 = Color3.new(1, 1, 1)
topLbl.TextScaled = true
topLbl.Font = Enum.Font.SourceSansBold
topLbl.Parent = top
-- scrolling area for items
local canvas = Instance.new("ScrollingFrame")
canvas.Size = UDim2.new(1, -20, 1, -60)
canvas.Position = UDim2.new(0, 10, 0, 50)
canvas.BackgroundTransparency = 1
canvas.BorderSizePixel = 0
canvas.ScrollBarThickness = 6
canvas.CanvasSize = UDim2.new(0, 0, 0, 0)
canvas.Parent = holder
-- GRID with extra spacing
local grid = Instance.new("UIGridLayout")
grid.CellSize = UDim2.new(0, 100, 0, 140)
grid.CellPadding = UDim2.new(0, 25, 0, 25)
grid.FillDirection = Enum.FillDirection.Horizontal
grid.SortOrder = Enum.SortOrder.LayoutOrder
grid.Parent = canvas
-- build items
for i, data in ipairs(ITEMS) do
local name, price, decalId, gearId = data.n, data.p, data.img, data.gear
local cell = Instance.new("Frame")
cell.Size = UDim2.new(0, 100, 0, 140)
cell.BackgroundTransparency = 0.5
cell.BackgroundColor3 = tan
cell.BorderSizePixel = 0
cell.LayoutOrder = i
cell.Parent = canvas
local cellOutline = Instance.new("UIStroke")
cellOutline.Color = outline
cellOutline.Thickness = 2
cellOutline.Parent = cell
-- image
local img = Instance.new("ImageLabel")
img.Size = UDim2.new(1, -10, 0, 80)
img.Position = UDim2.new(0, 5, 0, 5)
img.BackgroundTransparency = 1
img.BorderSizePixel = 0
img.Image = "rbxassetid://"..decalId
img.ScaleType = Enum.ScaleType.Fit
img.Parent = cell
-- name (WHITE + BOLD)
local nameLbl = Instance.new("TextLabel")
nameLbl.Size = UDim2.new(1, -10, 0, 20)
nameLbl.Position = UDim2.new(0, 5, 0, 90)
nameLbl.BackgroundTransparency = 1
nameLbl.Text = name
nameLbl.TextColor3 = Color3.new(1, 1, 1)
nameLbl.TextScaled = true
nameLbl.Font = Enum.Font.SourceSansBold
nameLbl.Parent = cell
-- price (WHITE + BOLD)
local priceLbl = Instance.new("TextLabel")
priceLbl.Size = UDim2.new(1, -10, 0, 15)
priceLbl.Position = UDim2.new(0, 5, 0, 110)
priceLbl.BackgroundTransparency = 1
priceLbl.Text = "$"..price
priceLbl.TextColor3 = Color3.new(1, 1, 1)
priceLbl.TextScaled = true
priceLbl.Font = Enum.Font.SourceSansBold
priceLbl.Parent = cell
-- buy button (BOLD)
local buy = Instance.new("TextButton")
buy.Size = UDim2.new(1, -10, 0, 20)
buy.Position = UDim2.new(0, 5, 0, 130)
buy.BackgroundColor3 = darkTan
buy.BorderSizePixel = 0
buy.Text = "BUY"
buy.TextColor3 = Color3.new(1, 1, 1)
buy.TextScaled = true
buy.Font = Enum.Font.SourceSansBold
buy.Parent = cell
buy.MouseButton1Click:Connect(function()
game:GetService("ReplicatedStorage").GiveGear:FireServer(gearId)
end)
end
-- open/close logic
local open = false
local tweenInfo = TweenInfo.new(0.4, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
tab.MouseButton1Click:Connect(function()
open = not open
tab.Text = open and "<" or ">"
local goal = open and UDim2.new(0.5, -300, 0.5, -200) or UDim2.new(0, -600, 0.5, -200)
ts:Create(holder, tweenInfo, {Position = goal}):Play()
end)
-- parent to starter gui
shop.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")Editor is loading...
Leave a Comment