local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") local UserInputService = game:GetService("UserInputService") local player = Players.LocalPlayer local playerGui = player:WaitForChild("PlayerGui") -- Check if ShopGui already exists, avoid duplication if playerGui:FindFirstChild("ShopGui") then return end -- Create ScreenGui and keep it after death local gui = Instance.new("ScreenGui") gui.Name = "ShopGui" gui.ResetOnSpawn = false -- IMPORTANT gui.Parent = playerGui -- Create main frame local frame = Instance.new("Frame") frame.Size = UDim2.new(0, 150, 0, 200) frame.Position = UDim2.new(0, 20, 0, 20) frame.BackgroundColor3 = Color3.fromRGB(50, 50, 50) frame.BorderSizePixel = 0 frame.Parent = gui -- Scrolling frame for buttons local scrollingFrame = Instance.new("ScrollingFrame") scrollingFrame.Size = UDim2.new(1, 0, 1, 0) scrollingFrame.CanvasSize = UDim2.new(0, 0, 0, 350) scrollingFrame.ScrollBarThickness = 8 scrollingFrame.BackgroundTransparency = 1 scrollingFrame.Parent = frame -- Layout inside scrolling frame local listLayout = Instance.new("UIListLayout") listLayout.SortOrder = Enum.SortOrder.LayoutOrder listLayout.Padding = UDim.new(0, 5) listLayout.Parent = scrollingFrame -- Button creation helper local function createButton(text, parent, callback) local btn = Instance.new("TextButton") btn.Size = UDim2.new(1, -10, 0, 40) btn.BackgroundColor3 = Color3.fromRGB(70, 70, 70) btn.TextColor3 = Color3.new(1, 1, 1) btn.Font = Enum.Font.SourceSansBold btn.TextSize = 18 btn.Text = text btn.Parent = parent btn.MouseButton1Click:Connect(callback) return btn end -- Define purchase functions local function buyShotgun() local args = { "BuyShopWeapon", workspace:WaitForChild("WeaponShops"):WaitForChild("DealerStore2"):WaitForChild("Items"):WaitForChild("Shotgun"), workspace:WaitForChild("WeaponShops"):WaitForChild("DealerStore2") } ReplicatedStorage.Events.GeneralEvent:FireServer(unpack(args)) end local function buyShotgunAmmo() local args = { "BuyShopWeaponAmmo", workspace:WaitForChild("WeaponShops"):WaitForChild("DealerStore2"):WaitForChild("Items"):WaitForChild("Shotgun") } ReplicatedStorage.Events.GeneralEvent:FireServer(unpack(args)) end local function buyVest() local args = { "BuyShopWeapon", workspace:WaitForChild("WeaponShops"):WaitForChild("GunShop"):WaitForChild("Items"):WaitForChild("Vest"), workspace:WaitForChild("WeaponShops"):WaitForChild("GunShop") } ReplicatedStorage.Events.GeneralEvent:FireServer(unpack(args)) end local function buySawedOff() local args = { "BuyShopWeapon", workspace:WaitForChild("WeaponShops"):WaitForChild("GunShop"):WaitForChild("Items"):WaitForChild("Sawed Off"), workspace:WaitForChild("WeaponShops"):WaitForChild("GunShop") } ReplicatedStorage.Events.GeneralEvent:FireServer(unpack(args)) end local function buySawedOffAmmo() local args = { "BuyShopWeaponAmmo", workspace:WaitForChild("WeaponShops"):WaitForChild("GunShop"):WaitForChild("Items"):WaitForChild("Sawed Off") } ReplicatedStorage.Events.GeneralEvent:FireServer(unpack(args)) end local function buyRevolver() local args = { "BuyShopWeapon", workspace:WaitForChild("WeaponShops"):WaitForChild("GunShop"):WaitForChild("Items"):WaitForChild("Revolver"), workspace:WaitForChild("WeaponShops"):WaitForChild("GunShop") } ReplicatedStorage.Events.GeneralEvent:FireServer(unpack(args)) end local function buyRevolverAmmo() local args = { "BuyShopWeaponAmmo", workspace:WaitForChild("WeaponShops"):WaitForChild("GunShop"):WaitForChild("Items"):WaitForChild("Revolver") } ReplicatedStorage.Events.GeneralEvent:FireServer(unpack(args)) end -- Create buttons in scrolling frame createButton("Shotgun", scrollingFrame, buyShotgun) createButton("Shotgun Ammo", scrollingFrame, buyShotgunAmmo) createButton("Vest", scrollingFrame, buyVest) createButton("Sawed Off", scrollingFrame, buySawedOff) createButton("Sawed Off Ammo", scrollingFrame, buySawedOffAmmo) createButton("Revolver", scrollingFrame, buyRevolver) createButton("Revolver Ammo", scrollingFrame, buyRevolverAmmo) -- Adjust canvas size local totalButtons = 7 local buttonHeight = 40 local padding = 5 local canvasHeight = totalButtons * (buttonHeight + padding) scrollingFrame.CanvasSize = UDim2.new(0, 0, 0, canvasHeight) -- Draggable frame code local dragging, dragInput, dragStart, startPos frame.InputBegan:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 then dragging = true dragStart = input.Position startPos = frame.Position input.Changed:Connect(function() if input.UserInputState == Enum.UserInputState.End then dragging = false end end) end end) frame.InputChanged:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseMovement then dragInput = input end end) UserInputService.InputChanged:Connect(function(input) if input == dragInput and dragging then local delta = input.Position - dragStart frame.Position = UDim2.new( startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y ) end end)