Advertisement
LawMixer

HelpWithThis

Sep 13th, 2021
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.46 KB | None | 0 0
  1. local PRICE_PREFIX = "%s Credits"
  2.  
  3. local BannerColors = {
  4. [true] = Color3.fromRGB(0, 255, 0);
  5. [false] = Color3.fromRGB(255, 0, 0);
  6. }
  7.  
  8. ----
  9.  
  10. local Player = game.Players.LocalPlayer
  11. local UserId = Player.UserId
  12.  
  13. local BuyRemote = game.ReplicatedStorage:WaitForChild("ShopBuy")
  14.  
  15. local UIControl = { }
  16. local ButtonControl = { }
  17.  
  18. if game:GetService("RunService"):IsServer() then return nil end
  19.  
  20. -- Services --
  21.  
  22. local TweenService = game:GetService("TweenService")
  23. local Market = game:GetService("MarketplaceService")
  24.  
  25. -- Resource --
  26.  
  27. local UtilModule = require(game.ReplicatedStorage:WaitForChild("Utils"))
  28.  
  29. local GuiResource = game.ReplicatedStorage:WaitForChild("GuiResource")
  30. local ShopResource = GuiResource:WaitForChild("Shop")
  31.  
  32. local SlotValues = require(game.ReplicatedStorage:WaitForChild("SmugglerPrices"))
  33.  
  34. -- Gui Variables --
  35.  
  36. local ScreenGui = script:FindFirstAncestorOfClass("ScreenGui")
  37. local Main = ScreenGui:WaitForChild("Main")
  38. local Holder = Main:WaitForChild("Background"):WaitForChild("Holder")
  39. local Ghost = game.ReplicatedStorage:WaitForChild("GuiResource"):WaitForChild("Ghost")
  40. local GhostOffset = UDim2.new(0.18900001, 0, 0.309000015, 0)
  41.  
  42. local QuintTweenInfo = TweenInfo.new(0.75, Enum.EasingStyle.Back, Enum.EasingDirection.In)
  43. local QuadTweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
  44. local ButtonTweenInfo = TweenInfo.new(0.35, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
  45.  
  46. local Click = script:FindFirstAncestorOfClass("ScreenGui"):FindFirstChild("Click")
  47.  
  48. -- Tween Sets --
  49.  
  50. local MainTweenOut = TweenService:Create(Main, QuintTweenInfo, {
  51. Size = UDim2.new(0, 0, 0, 0)
  52. })
  53. local MainTweenIn = TweenService:Create(Main, QuadTweenInfo, {
  54. Size = UDim2.new(1, 0, 1, 0)
  55. })
  56.  
  57. ----
  58.  
  59. function UIControl:Setup()
  60. local StartingTick = tick()
  61.  
  62. Main.Size = UDim2.new(0, 0, 0, 0)
  63. Main.Visible = false
  64.  
  65. ScreenGui.Enabled = true
  66.  
  67. for _, Slot in next, Holder:GetChildren() do
  68. local Button = Slot:FindFirstChild("Button")
  69. local Banner = Button:FindFirstChild("Banner")
  70. local Price = Banner:FindFirstChild("Price")
  71. local Title = Button:FindFirstChild("Title")
  72.  
  73. local Found, Amount = pcall(function() return SlotValues[tostring(Slot.Name)] end)
  74.  
  75. if Found then
  76.  
  77. Price.Text = string.format(PRICE_PREFIX, tostring(Amount))
  78.  
  79. local function updateBanner()
  80. local Credits = Player:FindFirstChild("Data"):FindFirstChild("Credits")
  81.  
  82. Banner.BackgroundColor3 = BannerColors[Credits.Value >= Amount]
  83. end
  84.  
  85. local TweenBannerIn = TweenService:Create(Banner, ButtonTweenInfo, {
  86. Position = UDim2.new(0, 0, 0.698, 0)
  87. })
  88. local TweenBannerOut = TweenService:Create(Banner, ButtonTweenInfo, {
  89. Position = UDim2.new(0, 0, 1.298, 0)
  90. })
  91.  
  92. local TweenTitleIn = TweenService:Create(Title, ButtonTweenInfo, {
  93. Position = UDim2.new(0.5, 0, 0.3, 0)
  94. })
  95. local TweenTitleOut = TweenService:Create(Title, ButtonTweenInfo, {
  96. Position = UDim2.new(0.5, 0, 0.5, 0)
  97. })
  98.  
  99. Button.MouseEnter:Connect(function()
  100. updateBanner()
  101.  
  102. TweenBannerIn:Play()
  103. TweenTitleIn:Play()
  104. end)
  105.  
  106. Button.MouseLeave:Connect(function()
  107. TweenBannerOut:Play()
  108. TweenTitleOut:Play()
  109. end)
  110.  
  111. local DB = false
  112.  
  113. Button.MouseButton1Down:Connect(function()
  114. if DB == false then
  115. DB = true
  116.  
  117. Click.TimePosition = 0.6
  118. Click:Play()
  119.  
  120. delay(1, function() DB = false end)
  121.  
  122. local Credits = Player:WaitForChild("Data"):FindFirstChild("Credits")
  123.  
  124. if Credits.Value <= Amount then
  125. BuyRemote:FireServer(Slot.Name)
  126.  
  127. GhostIcon(Button.Parent)
  128. end
  129.  
  130. end
  131. end)
  132. end
  133. end
  134. end
  135.  
  136. function GhostIcon(Icon)
  137. local NewGhost = Ghost:Clone()
  138. local Scale = NewGhost:FindFirstChild("UIScale")
  139.  
  140. NewGhost.Parent = Holder
  141.  
  142. local TweenOutTrans = TweenService:Create(NewGhost, QuadTweenInfo, {
  143. BackgroundTransparency = 1
  144. })
  145.  
  146. local TweenScale = TweenService:Create(Scale, QuadTweenInfo, {
  147. Scale = 1
  148. })
  149.  
  150. NewGhost.Position = Icon.Position + GhostOffset
  151. NewGhost.BackgroundTransparency = 0.5
  152. Scale.Scale = 0.5
  153.  
  154. TweenOutTrans:Play()
  155. TweenScale:Play()
  156.  
  157. TweenOutTrans.Completed:Wait()
  158.  
  159. NewGhost:Destroy()
  160.  
  161. end
  162.  
  163. function UIControl:Open()
  164. UtilModule:AddBlur(25)
  165.  
  166. Main.Visible = true
  167. MainTweenIn:Play()
  168. end
  169.  
  170. function UIControl:Close()
  171.  
  172. UtilModule:RemoveBlur()
  173. MainTweenOut:Play()
  174. end
  175.  
  176. return UIControl
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement