Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.72 KB | None | 0 0
  1. -- Core UI localscript
  2.  
  3. local availableTools = game.ReplicatedStorage:WaitForChild("GetTools"):InvokeServer()
  4. --local avalibleCosmetics = game.ReplicatedStorage:WaitForChild("CosmeticsMods"):InvokeServer()
  5. local mainFrame = script.Parent:WaitForChild("MainFrame")
  6. local safeArea = mainFrame:WaitForChild("SafeArea")
  7. local itemInformation = safeArea:WaitForChild("ItemInformation")
  8. local cosFrame = safeArea:WaitForChild("CosmeticsFrame")
  9. local infoFrame = itemInformation.InfoFrame
  10. local selectedItem = itemInformation.SelectedItem
  11. local equippedItem = itemInformation.EquippedItem
  12. local numberOfItems = #availableTools
  13. --local numberOfCos = #avalibleCosmetics
  14.  
  15. local itemFrame = safeArea.ItemFrame
  16. local buyButton = infoFrame.BuyButton
  17.  
  18.  
  19. --local equippedItemViewport = script.Parent:WaitForChild("EquippedItemViewport")
  20. local itemViewport = itemInformation.ItemViewport
  21.  
  22. local PADDING_X = 0.02
  23. local DROPDOWN_Y = 0.2
  24. local DROPDOWN_X = 0.25
  25.  
  26.  
  27. local item1 = itemFrame:WaitForChild("Item1")
  28. --local Cosmetic1 = cosFrame:WaitForChild("Cosmetic1")
  29.  
  30. local box
  31. local numRows = 1
  32.  
  33. --for l = 1,numberOfCos,1 do
  34. -- if l == 1 then
  35. -- box = Cosmetic1
  36. -- else
  37. -- box = Cosmetic1:Clone()
  38. -- box.Name = "Cosmetic"..l
  39. -- box.Parent = cosFrame
  40. --
  41. -- if (l-1) / (4*numRows) == 1 then
  42. -- numRows = numRows + 1
  43. -- box.Position = UDim2.new(PADDING_X,0,box.Position.Y.Scale,0) + UDim2.new(0,0,DROPDOWN_Y*(numRows-1),0)
  44. -- else
  45. -- box.Position = cosFrame["Cosmetic"..(l-1)].Position + UDim2.new(DROPDOWN_X,0,0,0)
  46. -- end
  47. -- end
  48. --end
  49.  
  50. for i = 1,numberOfItems,1 do
  51.  
  52. if i == 1 then
  53. -- Starting, so fill in Item1
  54. box = item1
  55. else
  56.  
  57. box = item1:Clone()
  58. box.Name = "Item"..i
  59. box.Parent = itemFrame
  60.  
  61. if (i-1) / (4*numRows) == 1 then
  62. numRows = numRows + 1
  63. box.Position = UDim2.new(PADDING_X,0,box.Position.Y.Scale,0) + UDim2.new(0,0,DROPDOWN_Y*(numRows-1),0)
  64. else
  65. box.Position = itemFrame["Item"..(i-1)].Position + UDim2.new(DROPDOWN_X,0,0,0)
  66. end
  67. end
  68.  
  69.  
  70. box.MouseButton1Click:Connect(function()
  71. local equipped = itemInformation.EquippedItem
  72. for _, v in pairs(itemViewport:GetChildren()) do
  73. if not v:IsA("Frame") then
  74. v:Destroy()
  75. end
  76. end
  77. local itemViewportCam = Instance.new("Camera")
  78. itemViewportCam.Parent = itemViewport
  79. local handle = game.ReplicatedStorage:WaitForChild("ToolModels"):FindFirstChild(availableTools[i][1].."Handle"):Clone()
  80. handle.Parent = itemViewport
  81. itemViewport.CurrentCamera = itemViewportCam
  82. itemViewportCam.CFrame = handle.CameraCFrame.Value
  83. local owned = game.ReplicatedStorage.ItemCheck:InvokeServer(availableTools[i][1])
  84. if equipped.Value == availableTools[i][1] then
  85. infoFrame.Cash.Text = "Owned"
  86. infoFrame.BuyButton.Text = "Unequip"
  87. elseif owned == true then
  88. infoFrame.BuyButton.Text = "Equip"
  89. infoFrame.Cash.Text = "Owned"
  90. else
  91. infoFrame.BuyButton.Text = "Buy"
  92. infoFrame.Cash.Text = "$"..availableTools[i][2]
  93. end
  94. infoFrame.ItemName.Text = availableTools[i][1]
  95. selectedItem.Value = availableTools[i][1]
  96.  
  97. for _, v in pairs(itemFrame:GetChildren()) do
  98. if v:IsA("ImageButton") then
  99. v.BorderSizePixel = 0
  100. end
  101. end
  102.  
  103. itemFrame["Item"..i].BorderSizePixel = 2
  104. end)
  105.  
  106. local fakeCam = Instance.new("Camera")
  107. fakeCam.Parent = box.VPF
  108. local handle = game.ReplicatedStorage:WaitForChild("ToolModels"):FindFirstChild(availableTools[i][1].."Handle"):Clone()
  109. handle.Parent = box.VPF
  110. box.VPF.CurrentCamera = fakeCam
  111. fakeCam.CFrame = handle.CameraCFrame.Value
  112. itemFrame["Item"..i].ItemName.Text = availableTools[i][1]
  113.  
  114. end
  115.  
  116. -- Buy Btn
  117.  
  118. buyButton.Activated:Connect(function()
  119. local result = game.ReplicatedStorage.PurchaseItem:InvokeServer(selectedItem.Value)
  120. if result == true then
  121. buyButton.BackgroundColor3 = Color3.fromRGB(42, 149, 42)
  122. buyButton.Text = "Bought!"
  123. wait(.5)
  124. buyButton.Text = "Equip"
  125. buyButton.BackgroundColor3 = Color3.fromRGB(55, 193, 55)
  126. elseif result == "NotEnoughBucks" then
  127. buyButton.BackgroundColor3 = Color3.fromRGB(204,31,31)
  128. buyButton.Text = "Not enough bucks!"
  129. wait(.5)
  130. buyButton.Text = "Buy"
  131. buyButton.BackgroundColor3 = Color3.fromRGB(55, 193, 55)
  132. elseif result == "Equipped" then
  133. equippedItem.Value = selectedItem.Value
  134. buyButton.BackgroundColor3 = Color3.fromRGB(42,149,42)
  135. buyButton.Text = "Equipped!"
  136. wait(.5)
  137. buyButton.Text = "Unequip"
  138. buyButton.BackgroundColor3 = Color3.fromRGB(55, 193, 55)
  139. elseif result == "Unequipped" then
  140. equippedItem.Value = ""
  141. buyButton.BackgroundColor3 = Color3.fromRGB(42,149,42)
  142. buyButton.Text = "Unequipped!"
  143. wait(.5)
  144. buyButton.Text = "Equip"
  145. buyButton.BackgroundColor3 = Color3.fromRGB(55, 193, 55)
  146. end
  147. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement