Aquarius_Raverus

Title System for Hidden

Apr 12th, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.97 KB | None | 0 0
  1. -- Title System Handler
  2.  
  3.  
  4. local Players = game:GetService("Players")
  5.  
  6. local RankTemplate = script:WaitForChild("RankTags")
  7. local ExploitReason = 'No exploiters allowed. To gulag you go. If you believe this to be false, join the discord server, and file a bug report.'
  8.  
  9. local Titles = { -- Put all the titles into this table.
  10.    
  11.     --// [NumberOrder] = {'NameOfTitle', AmountNeeded};
  12.     --// Testing Currency: Coins
  13.    
  14.     [1] = {'Test', 10};
  15.     [2] = {'Ez', 20};
  16.    
  17.    
  18. }
  19.  
  20. local PassableActions = { -- Passable Commands that you can execute.
  21.    
  22.     [1] = {'applyTitle'};
  23.     [2] = {'removeTitle'}
  24. }
  25.  
  26. function titleFunction(plr, action)
  27.     if not plr:FindFirstChild('Titles') then return end
  28.     if not plr:FindFirstChild('Coins') then return end
  29.    
  30.     for i, actions in pairs(PassableActions) do
  31.         if action == PassableActions[i] then
  32.             plr:Kick(ExploitReason)
  33.         end
  34.     end
  35.    
  36.     if action == 'applyTitle' then
  37.         for i,list in pairs(Titles) do
  38.             if plr.Coins.Value == Titles[i][2] then
  39.                 print('ez')
  40.                    
  41.                 local clone = RankTemplate:Clone()
  42.                 clone.Parent = plr.Character.Head
  43.                 clone.Name = Titles[i][1]
  44.                
  45.                 clone.Title.Text = Titles[i][1]
  46.                
  47.                 local titleValue = Instance.new("BoolValue", plr.Titles)
  48.                 titleValue.Name = 'HasTitle'
  49.                 titleValue.Value = true
  50.                
  51.                 break
  52.             else
  53.                 warn('this player does not meet requirements')
  54.                 break
  55.             end
  56.         end
  57.     end
  58.    
  59.     if action == 'removeTitle' then
  60.         local findValue = plr.Titles:FindFirstChild('HasTitle')
  61.         if not findValue then return end
  62.         if findValue.Value == false then return plr:Kick(ExploitReason) end
  63.        
  64.         if findValue.Value == true then
  65.             findValue:Destroy()
  66.         end
  67.     end
  68. end
  69.  
  70.  
  71. Players.PlayerAdded:Connect(function(plr)
  72.     if plr then
  73.         local stats = Instance.new("Folder", plr)
  74.         stats.Name = 'Titles'
  75.        
  76.         local Coins = Instance.new("IntValue", plr)
  77.         Coins.Name = 'Coins'
  78.         Coins.Value = 10
  79.     end
  80.    
  81.     plr.CharacterAdded:Connect(function(char)
  82.         titleFunction(plr, 'applyTitle')
  83.     end)
  84. end)
Add Comment
Please, Sign In to add comment