Advertisement
Guest User

The Northern Frontier Shop GUI script

a guest
Apr 18th, 2020
2,883
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.65 KB | None | 0 0
  1. -- Updated by el1te
  2.  
  3. if game.CoreGui:FindFirstChild("TNFSHOP") then
  4.   game.CoreGui:FindFirstChild("TNFSHOP"):Destroy()
  5. end
  6.  
  7. local Players = game:GetService("Players")
  8. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  9. local Remote = ReplicatedStorage:WaitForChild("Resources"):WaitForChild("Remotes"):WaitForChild("ClientRequest")
  10.  
  11. local Directory = {
  12.   ["generalStore1"] = {
  13.     "Wooden chest",  
  14.     "Flintlock ball",
  15.     "Model 1777",
  16.     "Bandage",
  17.     "Bread",
  18.     "Dual pistol",
  19.     "Blunderbuss",
  20.     "Charleville musket",
  21.     "Kentucky rifle",
  22.     "Bedroll",
  23.     "Hungarian axe pistol",
  24.     "Faction uniform",
  25.     "Marksman rifle",
  26.     "Bullet",
  27.     "Pocket watch",
  28.     "Simple iron knife",
  29.     "Lantern",
  30.     "Fishing pole",
  31.     "Pickaxe",
  32.     "Torch",
  33.     "Compass",
  34.     "Spyglass"
  35.   },
  36.   ["illegalSupplies"] = {
  37.     "Two-barrel musket",
  38.     "Denix pistol",
  39.     "War axe",
  40.     "Long pistol"
  41.   },
  42.   ["tailor"] = {
  43.     "Glasses",
  44.     "Deluxe bandana"
  45.    
  46.   },
  47.   ["barberShop"] = {
  48.     ["Spanish helmet"] = game:GetService("Workspace").World.Operables["Hudson Bay Tailorship"]["Spanish helmet"],
  49.     ["Seafarer"] = game:GetService("Workspace").World.Operables["Hudson Bay Tailorship"].Seafarer
  50.   },
  51.   ["travelSupplies"] = {
  52.     "Large knapsack"
  53.   },
  54.   ["eventshop"] = {
  55.     "Faction scarf"
  56.   }
  57. }
  58.  
  59. local function PurchaseItem(shop, item, quantity, itemLocation)
  60.   local quantity = quantity or 1
  61.   if itemLocation then
  62.   return Remote:InvokeServer("purchaseItem", shop, item, quantity, itemLocation)
  63.   else
  64.     return Remote:InvokeServer("purchaseItem", shop, item, quantity)
  65.   end
  66. end
  67. local function SellItem()
  68.  
  69. end
  70. local function Drag(frame)
  71.   local UserInputService = game:GetService("UserInputService")
  72.  
  73.   local gui = frame
  74.  
  75.   local dragging
  76.   local dragInput
  77.   local dragStart
  78.   local startPos
  79.  
  80.   local function update(input)
  81.     local delta = input.Position - dragStart
  82.     gui.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
  83.   end
  84.  
  85.   gui.InputBegan:Connect(function(input)
  86.     if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
  87.       dragging = true
  88.       dragStart = input.Position
  89.       startPos = gui.Position
  90.      
  91.       input.Changed:Connect(function()
  92.         if input.UserInputState == Enum.UserInputState.End then
  93.           dragging = false
  94.         end
  95.       end)
  96.     end
  97.   end)
  98.  
  99.   gui.InputChanged:Connect(function(input)
  100.     if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
  101.       dragInput = input
  102.     end
  103.   end)
  104.  
  105.   UserInputService.InputChanged:Connect(function(input)
  106.     if input == dragInput and dragging then
  107.       update(input)
  108.     end
  109.   end)
  110. end
  111.  
  112. local MainGui = Instance.new("ScreenGui")
  113. MainGui.Name = "TNFSHOP"
  114. MainGui.ResetOnSpawn = false
  115.  
  116. local TopBar = Instance.new("Frame")
  117. TopBar.Name = "TopBar"
  118. TopBar.Position = UDim2.new()
  119. TopBar.Size = UDim2.new(0, 300, 0, 30)
  120. -- change top bar color below
  121. TopBar.BackgroundColor3 = Color3.fromRGB(128, 128, 128)
  122. -- change top bar color above
  123. TopBar.BorderSizePixel = 0
  124. TopBar.Active = true
  125. TopBar.Draggable = false
  126. TopBar.Parent = MainGui
  127. Drag(TopBar)
  128.  
  129. local CloseButton = Instance.new("TextButton")
  130. CloseButton.Name = "CloseButton"
  131. CloseButton.Position = UDim2.new(1, -30, 0, 0)
  132. CloseButton.Size = UDim2.new(0, 30, 0, 30)
  133. CloseButton.BackgroundColor3 = Color3.fromRGB(128, 128, 128)
  134. CloseButton.BorderSizePixel = 0
  135. CloseButton.TextSize = 15
  136. CloseButton.Text = "X"
  137. CloseButton.Parent = TopBar
  138.  
  139. local Frame = Instance.new("ScrollingFrame")
  140. Frame.Name = "ShopFrame"
  141. Frame.CanvasSize = UDim2.new(0, 300, 0, 1100)
  142. Frame.Position = UDim2.new(0, 0, 0, 30)
  143. Frame.Size = UDim2.new(0, 300, 0, 500)
  144. -- change frame color below
  145. Frame.BackgroundColor3 = Color3.fromRGB(128, 128, 128)
  146. -- change frame color above
  147. Frame.BorderSizePixel = 0
  148. Frame.ScrollBarImageColor3 = Color3.fromRGB(0, 0, 0)
  149. Frame.Active = true
  150. Frame.Draggable = false
  151. Frame.Parent = TopBar
  152.  
  153. local Layout = Instance.new("UIListLayout")
  154. Layout.HorizontalAlignment = Enum.HorizontalAlignment.Center
  155. Layout.Padding = UDim.new(0, 10)
  156. Layout.Parent = Frame
  157.  
  158. local ItemsCreated = 0
  159. local function AddItem(itemName, shop, defaultquantity, func, itemLocation)
  160.   ItemsCreated = ItemsCreated + 1
  161.   if not defaultquantity then defaultquantity = 1 end
  162.   local ItemFrame = Instance.new("Frame")
  163.   ItemFrame.Name = itemName
  164.   ItemFrame.BorderSizePixel = 0
  165.   ItemFrame.Size = UDim2.new(0, 240, 0, 80)
  166.  
  167.   local ItemLabel = Instance.new("TextLabel")
  168.   ItemLabel.Name = "ItemLabel"
  169.   ItemLabel.Text = itemName
  170.   ItemLabel.Position = UDim2.new(0, 3, 0, 0)
  171.   ItemLabel.Size = UDim2.new(0, 230, 0, 20)
  172.   ItemLabel.BorderSizePixel = 0
  173.   ItemLabel.TextXAlignment = Enum.TextXAlignment.Left
  174.   ItemLabel.Parent = ItemFrame
  175.  
  176.   local ItemQuantity = Instance.new("TextBox")
  177.   ItemQuantity.Name = "ItemQuantity"
  178.   ItemQuantity.Text = tostring(defaultquantity)
  179.   ItemQuantity.TextSize = 20
  180.   ItemQuantity.Size = UDim2.new(0, 100, 0, 40)
  181.   ItemQuantity.Position = UDim2.new(0, 20, 0, 30)
  182.   ItemQuantity.Parent = ItemFrame
  183.  
  184.   local ItemPurchase = Instance.new("TextButton")
  185.   ItemPurchase.Name = "ItemPurchase"
  186.   ItemPurchase.Text = "Purchase"
  187.   ItemPurchase.TextSize = 15
  188.   ItemPurchase.Size = UDim2.new(0, 100, 0 , 40)
  189.   ItemPurchase.Position = UDim2.new(0, 120, 0, 30)
  190.   ItemPurchase.Parent = ItemFrame
  191.  
  192.   local func = func or function()
  193.     local quantity = tonumber(ItemQuantity.Text) or 1
  194.     local response = PurchaseItem(shop, itemName, quantity, itemLocation)
  195.   end
  196.   ItemPurchase.MouseButton1Click:Connect(func)
  197.  
  198.   ItemFrame.Parent = Frame
  199.   return ItemFrame
  200. end
  201.  
  202. for shopName, v in pairs(Directory) do
  203.   if shopName == "barberShop" then
  204.     for itemName, itemLocation in pairs(v) do
  205.       AddItem(itemName, shopName, 1, nil, itemLocation)
  206.     end
  207.   else
  208.     for i, itemName in ipairs(v) do
  209.       AddItem(itemName, shopName, 1)
  210.     end
  211.   end
  212. end
  213.  
  214. Frame.CanvasSize = UDim2.new(0, 300, 0, 90 * ItemsCreated)
  215.  
  216. local Closed = false
  217. CloseButton.MouseButton1Click:Connect(function()
  218.   if not Closed then
  219.     Closed = true
  220.     Frame.Parent = nil
  221.     TopBar.Size = UDim2.new(0, 45, 0, 45)
  222.     CloseButton.Position = UDim2.new(0.5, -15, 0.5, -15)
  223.   elseif Closed then
  224.     Closed = false
  225.     TopBar.Size = UDim2.new(0, 300, 0, 30)
  226.     CloseButton.Position = UDim2.new(1, -30, 0, 0)
  227.     Frame.Parent = TopBar
  228.   end
  229. end)
  230. MainGui.Parent = game.CoreGui
  231. wait()
  232. MainGui.AncestryChanged:Connect(function(_, parent)
  233.   if not parent then
  234.     script:Destroy()
  235.   end
  236. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement