Shop GUI

Video Tutorials

Getting Started

Part 1

Adding Buttons

Part 2

Giving Items to Player

Part 3

Charging for Items

Part 4

Open Close Menu (Part 1)

local frame = script.Parent
local openPart = game.Workspace.Part
local offPart = game.Workspace.off
local closeButton = script.Parent.close
local canShop = true

frame.Visible = false

local function shopMenu(otherPart)
    local playerName = otherPart.Parent.Name
    local player = game.Players:FindFirstChild(playerName)
    player.Character.Humanoid.WalkSpeed = 0
    player.PlayerGui.ScreenGui.Frame.Visible = true
end

local function closeShop()
    local player = game.Players.LocalPlayer
    player.Character.Humanoid.WalkSpeed = 16
    player.PlayerGui.ScreenGui.Frame.Visible = false
    player.Character.HumanoidRootPart.CFrame = CFrame.new(offPart.Position.X,offPart.Position.Y+5,offPart.Position.Z)
end

openPart.Touched:Connect(shopMenu)
closeButton.MouseButton1Click:Connect(closeShop)

Print Bought (Part 2)

local frame = script.Parent
local openPart = game.Workspace.Part
local offPart = game.Workspace.off
local closeButton = script.Parent.close
local canShop = true
local buy_1 = script.Parent.buy1
local buy_2 = script.Parent.buy2
local buy_3 = script.Parent.buy3

frame.Visible = false

local function shopMenu(otherPart)
    local playerName = otherPart.Parent.Name
    local player = game.Players:FindFirstChild(playerName)
    player.Character.Humanoid.WalkSpeed = 0
    player.PlayerGui.ScreenGui.Frame.Visible = true
end

local function closeShop()
    local player = game.Players.LocalPlayer
    player.Character.Humanoid.WalkSpeed = 16
    player.PlayerGui.ScreenGui.Frame.Visible = false
    player.Character.HumanoidRootPart.CFrame = CFrame.new(offPart.Position.X,offPart.Position.Y+5,offPart.Position.Z)
end

local function buyItem1()
    print('Bought Item 1')
end

local function buyItem2()
    print('Bought Item 2')
end

local function buyItem3()
    print('Bought Item 3')
end

openPart.Touched:Connect(shopMenu)
closeButton.MouseButton1Click:Connect(closeShop)
buy_1.MouseButton1Click:Connect(buyItem1)
buy_2.MouseButton1Click:Connect(buyItem2)
buy_3.MouseButton1Click:Connect(buyItem3)

Leaderstats

local function onPlayerJoin(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player
 

    local gold = Instance.new("IntValue")
    gold.Name = "Gold"
    gold.Value = 5000
    gold.Parent = leaderstats
end

Receive Info from Client (Part 3)

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")

local function onPlayerJoin(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player
 

    local gold = Instance.new("IntValue")
    gold.Name = "Gold"
    gold.Value = 5000
    gold.Parent = leaderstats
end
 
local function buyTool(player, toolName)
    print(player)
    print(toolName)  
end
 
remoteEvent.OnServerEvent:Connect(buyTool)

game.Players.PlayerAdded:Connect(onPlayerJoin)

Final Scripts

Notes:

Add a RemoteEvent to Replicated Storage

Add tools that are being sold under Replicated Storage

Each tool should have have an IntValue renamed to Price

Set the value of that IntValue to what you want the price of the tool to be

If you name parts or tools other names make sure to update the appropriate lines in the script as well

Remote Event (ServerScriptService) Final

local openPart = game.Workspace.Part

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")

local Players = game:GetService("Players")


local function displayShop(otherPart)
    local humanoid = otherPart.Parent:FindFirstChildWhichIsA('Humanoid')
    if humanoid then
        local player = Players:FindFirstChild(otherPart.Parent.Name)
        if player then
            remoteEvent:FireClient(player)
        end
    end
end

openPart.Touched:Connect(displayShop)

PlayerSetup (ServerScriptService) Final

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")

local function onPlayerJoin(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player
 

    local gold = Instance.new("IntValue")
    gold.Name = "Gold"
    gold.Value = 5000
    gold.Parent = leaderstats
end
 
local function buyTool(player, tool)
    if player.leaderstats.Gold.Value > tool.Price.Value then
        player.leaderstats.Gold.Value = player.leaderstats.Gold.Value - tool.Price.Value
        local giveTool = ReplicatedStorage[tool.Name]:clone()
        giveTool.Parent = player.Backpack

        local giveTool = ReplicatedStorage[tool.Name]:clone()
        giveTool.Parent = player.StarterGear
   end   
end
 
remoteEvent.OnServerEvent:Connect(buyTool)

game.Players.PlayerAdded:Connect(onPlayerJoin)

LocalScript Under Frame (Final)

local frame = script.Parent
local openPart = game.Workspace.Part
local offPart = game.Workspace.off
local closeButton = script.Parent.close
local canShop = true
local buy_1 = script.Parent.buy1
local buy_2 = script.Parent.buy2
local buy_3 = script.Parent.buy3

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")

frame.Visible = false

local function shopMenu()
  local player = game.Players.LocalPlayer
    player.Character.Humanoid.WalkSpeed = 0
    player.PlayerGui.ScreenGui.Frame.Visible = true
end

local function closeShop()
    local player = game.Players.LocalPlayer
    player.Character.Humanoid.WalkSpeed = 16
    player.PlayerGui.ScreenGui.Frame.Visible = false
    player.Character.HumanoidRootPart.CFrame = CFrame.new(offPart.Position.X,offPart.Position.Y+5,offPart.Position.Z)
end

local function buyItem1(player)
    local toolName = ReplicatedStorage.Tool1
    remoteEvent:FireServer(toolName)
end

local function buyItem2()
    local toolName = ReplicatedStorage.Tool2
    remoteEvent:FireServer(toolName)
end

local function buyItem3()
    local toolName = ReplicatedStorage.Tool3
    remoteEvent:FireServer(toolName)
end

remoteEvent.OnClientEvent:Connect(shopMenu)
closeButton.MouseButton1Click:Connect(closeShop)
buy_1.MouseButton1Click:Connect(buyItem1)
buy_2.MouseButton1Click:Connect(buyItem2)
buy_3.MouseButton1Click:Connect(buyItem3)