HowToRoblox

GuiHandler

Mar 4th, 2021
1,721
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local btn = script.Parent:WaitForChild("ShopBtn")
  2. local shopFrame = script.Parent:WaitForChild("ShopBG")
  3. local itemScroller = shopFrame.ItemScroller
  4. local itemPreview = shopFrame.ItemPreview
  5.  
  6.  
  7. shopFrame.Visible = false
  8. itemPreview.Visible = false
  9.  
  10.  
  11. btn.MouseButton1Click:Connect(function()
  12.    
  13.     shopFrame.Visible = not shopFrame.Visible
  14. end)
  15.  
  16.  
  17. local itemsFolder = game.ReplicatedStorage:WaitForChild("Items")
  18.  
  19. for i, item in pairs(itemsFolder:GetChildren()) do
  20.    
  21.    
  22.     local name = item.Name
  23.     local price = item.ShopGuiInfo.Price.Value
  24.     local desc = item.ShopGuiInfo.Description.Value
  25.    
  26.     local itemSelection = script.ItemSelection:Clone()
  27.    
  28.     local cam = Instance.new("Camera")
  29.     cam.Parent = itemSelection.ItemView
  30.     itemSelection.ItemView.CurrentCamera = cam
  31.    
  32.    
  33.     local displayPart = item.Handle:Clone()
  34.     displayPart.Anchored = true
  35.     displayPart.CFrame = CFrame.new()
  36.     displayPart.Parent = itemSelection.ItemView
  37.    
  38.     cam.CFrame = CFrame.new(displayPart.Position + displayPart.CFrame.LookVector * 4, displayPart.Position)
  39.    
  40.     itemSelection.Parent = itemScroller
  41.    
  42.    
  43.     itemSelection.MouseButton1Click:Connect(function()
  44.        
  45.         itemPreview.ItemName.Text = name
  46.         itemPreview.BuyButton.Text = "Buy for " .. price
  47.         itemPreview.ItemDescription.Text = desc
  48.        
  49.         if itemPreview.ItemImage:FindFirstChild("Handle") then itemPreview.ItemImage.Handle:Destroy() end
  50.         if itemPreview.ItemImage:FindFirstChild("Camera") then itemPreview.ItemImage.Camera:Destroy() end
  51.        
  52.         local cam2 = cam:Clone()
  53.         cam2.Parent = itemPreview.ItemImage
  54.         itemPreview.ItemImage.CurrentCamera = cam2
  55.        
  56.         displayPart:Clone().Parent = itemPreview.ItemImage
  57.        
  58.         itemPreview.Visible = true
  59.     end)
  60. end
  61.  
  62.  
  63. itemPreview.BuyButton.MouseButton1Click:Connect(function()
  64.  
  65.     game.ReplicatedStorage.OnItemBought:FireServer(itemsFolder[itemPreview.ItemName.Text])
  66. end)
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×