Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.60 KB | None | 0 0
  1. --// Services
  2. local Players = game:GetService("Players")
  3. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  4.  
  5. --// Assets
  6. local Remotes = ReplicatedStorage:WaitForChild("Remotes")
  7. local ClassEvent = Remotes:WaitForChild("Class")
  8. local DataEvent = Remotes:WaitForChild("Data")
  9.  
  10. local Modules = ReplicatedStorage:WaitForChild("Modules")
  11. local ClassInfo = require(Modules:WaitForChild("Class Info"))
  12.  
  13. local Hotbar = require(script.Parent:WaitForChild("Hotbar"))
  14.  
  15. --// Variables
  16. local Player = Players.LocalPlayer
  17. local PlayerGui = Player:WaitForChild("PlayerGui")
  18.  
  19. local Gui = PlayerGui:WaitForChild("Character Selection")
  20. local Background = Gui:WaitForChild("Background")
  21.  
  22. local Select = Background:WaitForChild("Select")
  23. local Price = Select:WaitForChild("Price")
  24. local Cash = Background:WaitForChild("Cash")
  25.  
  26. local Selected = {
  27.     Character = "",
  28.     Anime = "",
  29. }
  30. local PlayerData = nil
  31.  
  32. --// Module
  33. local module = {
  34.     Enable = function()
  35.         Gui.Enabled = true
  36.        
  37.         local BackgroundAssets = Background:GetDescendants()
  38.         for index = 1,#BackgroundAssets do
  39.             local Button = BackgroundAssets[index]
  40.             if Button:IsA("TextButton") or Button:IsA("ImageButton") then
  41.                 if Button.Name == "Select" then return end
  42.                 Button.MouseButton1Click:Connect(function()
  43.                     if Selected.Character == Button.Name or Selected.Anime == Button.Parent.Name then
  44.                         Selected.Character = nil
  45.                         Selected.Anime = nil
  46.                         Select.Text = ""
  47.                         Price.Visible = false
  48.                         Price.Text = ""
  49.                     else
  50.                         if PlayerData.Characters[Button.Parent.Name][Button.Name] == "Locked" then
  51.                             Selected.Character = Button.Name
  52.                             Selected.Anime = Button.Parent.Name
  53.                             Select.Text = "Buy"
  54.                             Price.Visible = true                       
  55.                             Price.Text = ClassInfo[Button.Parent.Name][Button.Name].Price
  56.                            
  57.                         else
  58.                             Selected.Character = Button.Name
  59.                             Selected.Anime = Button.Parent.Name
  60.                             Select.Text = "Select"
  61.                             Price.Visible = false
  62.                             Price.Text = ""
  63.                         end
  64.                     end
  65.                 end)
  66.                
  67.             end
  68.         end
  69.     end,
  70.    
  71.     Toggle = function(Task)
  72.         if Task == "On" then
  73.             Gui.Enabled = true
  74.         elseif Task == "Off" then
  75.             Gui.Enabled = false
  76.         end
  77.     end
  78. }
  79.  
  80. --// Main
  81. Select.MouseButton1Click:Connect(function()
  82.     if Selected.Character or Selected.Anime == nil then return end
  83.     if PlayerData.Characters[Selected.Anime][Selected.Character] == "Unlocked" then
  84.         ClassEvent:FireServer({Selected.Anime, Selected.Character})
  85.     else
  86.  
  87.     end
  88. end)
  89.  
  90. DataEvent.OnClientEvent:Connect(function(Data)
  91.     PlayerData = Data
  92.     Cash.Text = Data.Stats.Cash
  93. end)
  94.  
  95. module.Enable()
  96.  
  97. return module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement