Advertisement
1x_Gacha

Shop | Local

Aug 16th, 2020 (edited)
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.13 KB | None | 0 0
  1. local parent = script.Parent
  2.  
  3. local sample = script.Sample
  4. local player = game.Players.LocalPlayer
  5.  
  6. local storage = game:GetService('ReplicatedStorage')
  7. local resources = storage:WaitForChild('Resources')
  8.  
  9. local remotes = storage:WaitForChild('Remotes')
  10. local remote = remotes:WaitForChild('BlackMarket')
  11.  
  12. local m = require(resources:WaitForChild('Blackmarket'))
  13.  
  14. local desc = parent:WaitForChild('Desc')
  15. local main = parent:WaitForChild('Main')
  16. local holder = desc:WaitForChild('Holder')
  17. local exit = parent:WaitForChild('Exit')
  18.  
  19. local item = desc:WaitForChild('Item')
  20.  
  21. local deb = false
  22.  
  23. local currentitem = nil
  24.  
  25. local function clean()
  26.     currentitem = nil
  27.     holder.Owned.Text = 'Owned : '
  28.     holder.Price.Text = 'Price : '
  29.     holder.Type.Text = 'Type : '
  30.     item.Text = ' '
  31. end
  32.  
  33. local function exitEvent()
  34.     if deb then return end
  35.     deb = true
  36.     clean()
  37.     remote:FireServer('EXIT')
  38.     wait(1)
  39.     deb = false
  40. end
  41.  
  42. exit.MouseButton1Click:Connect(exitEvent)
  43.  
  44. local function purchaseEvent()
  45.     if currentitem == nil then return end
  46.     if deb then return end
  47.     deb = true
  48.     remote:FireServer('PURCHASE', currentitem)
  49.     wait(1)
  50.     local i = 0
  51.     for e,d in pairs(player:WaitForChild('Backpack'):GetChildren())do
  52.         if d.Name == currentitem then
  53.             i = i+1
  54.         end
  55.     end
  56.     holder.Owned.Text = 'Owned : '..tostring(i)
  57.     wait(.5)
  58.     deb = false
  59. end
  60.  
  61. holder.Purchase.MouseButton1Click:Connect(purchaseEvent)
  62.  
  63. for i,v in pairs(m.Items)do
  64.     if main:FindFirstChild(v.name) then return end
  65.     local c = sample:Clone()
  66.     c.Text = v.name
  67.     c.Name = v.name
  68.     c.Parent = main
  69.     c.MouseButton1Click:Connect(function()
  70.         if deb then return end
  71.         deb = true
  72.         if c.Name == currentitem then
  73.             currentitem = nil
  74.              clean()
  75.         else
  76.             clean()
  77.             currentitem = c.Name
  78.             holder.Price.Text = 'Price : '..m.Items[c.Name]['price']
  79.             item.Text = m.Items[c.Name]['name']
  80.             holder.Type.Text = 'Type : '..m.Items[c.Name]['type']
  81.             local i = 0
  82.             for e,d in pairs(player:WaitForChild('Backpack'):GetChildren())do
  83.                 if d.Name == c.Name then
  84.                     i = i+1
  85.                 end
  86.             end
  87.             holder.Owned.Text = 'Owned : '..tostring(i)
  88.         end
  89.         wait(.2)
  90.         deb = false
  91.     end)
  92. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement