HowToRoblox

ShopClient

Dec 6th, 2021
917
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local re = game.ReplicatedStorage:WaitForChild("ShopRE")
  2. local shop = game.ReplicatedStorage:WaitForChild("DailyShop")
  3.  
  4. script.Parent.ShopFrame.Visible = false
  5.  
  6.  
  7. local function createShop()
  8.    
  9.     for i, c in pairs(script.Parent.ShopFrame.ShopScroller:GetChildren()) do
  10.        
  11.         if c:IsA("Frame") then c:Destroy() end
  12.     end
  13.    
  14.     for i, c in pairs(shop:GetChildren()) do
  15.        
  16.         local itemFrame = script.ItemTemplate:Clone()
  17.        
  18.         itemFrame.ItemName.Text = c.Name
  19.         itemFrame.ItemCost.Text = "costs $" .. c:WaitForChild("Price").Value
  20.        
  21.         if c.TextureId then
  22.            
  23.             local img = Instance.new("ImageLabel", itemFrame.ItemDisplay)
  24.             img.Size = UDim2.new(1, 0, 1, 0)
  25.             img.Image = c.TextureId
  26.             img.BackgroundTransparency = 1
  27.            
  28.         else
  29.            
  30.             local displayItem = c:Clone()
  31.             displayItem.Parent = itemFrame.ItemDisplay
  32.            
  33.             local cam = Instance.new("Camera", itemFrame.ItemDisplay)
  34.             itemFrame.ItemDisplay.CurrentCamera = cam
  35.            
  36.             cam.CFrame = CFrame.new(displayItem.Position - displayItem.CFrame.LookVector * 3, displayItem.Position)
  37.         end
  38.        
  39.         itemFrame.BuyButton.MouseButton1Click:Connect(function()
  40.            
  41.             re:FireServer(c)
  42.         end)
  43.        
  44.         itemFrame.Parent = script.Parent.ShopFrame.ShopScroller
  45.        
  46.         script.Parent.ShopFrame.ShopScroller.CanvasSize = UDim2.new(0, 0, 0, script.Parent.ShopFrame.ShopScroller.UIListLayout.AbsoluteContentSize.Y)
  47.     end
  48. end
  49.  
  50. createShop()
  51.  
  52. shop.ChildAdded:Connect(createShop)
  53.  
  54. game.ReplicatedStorage.TimeForReset.Changed:Connect(function()
  55.    
  56.     script.Parent.ShopFrame.ResetTime.Text = "resets in " .. game.ReplicatedStorage.TimeForReset.Value
  57. end)
  58.  
  59.  
  60. script.Parent.ShopButton.MouseButton1Click:Connect(function()
  61.     script.Parent.ShopFrame.Visible = not script.Parent.ShopFrame.Visible
  62. end)
  63.  
  64. script.Parent.ShopFrame.CloseButton.MouseButton1Click:Connect(function()
  65.     script.Parent.ShopFrame.Visible = false
  66. end)
RAW Paste Data