Advertisement
LawMixer

ModuleScript

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