Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Title System Handler
- local Players = game:GetService("Players")
- local RankTemplate = script:WaitForChild("RankTags")
- 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.'
- local Titles = { -- Put all the titles into this table.
- --// [NumberOrder] = {'NameOfTitle', AmountNeeded};
- --// Testing Currency: Coins
- [1] = {'Test', 10};
- [2] = {'Ez', 20};
- }
- local PassableActions = { -- Passable Commands that you can execute.
- [1] = {'applyTitle'};
- [2] = {'removeTitle'}
- }
- function titleFunction(plr, action)
- if not plr:FindFirstChild('Titles') then return end
- if not plr:FindFirstChild('Coins') then return end
- for i, actions in pairs(PassableActions) do
- if action == PassableActions[i] then
- plr:Kick(ExploitReason)
- end
- end
- if action == 'applyTitle' then
- for i,list in pairs(Titles) do
- if plr.Coins.Value == Titles[i][2] then
- print('ez')
- local clone = RankTemplate:Clone()
- clone.Parent = plr.Character.Head
- clone.Name = Titles[i][1]
- clone.Title.Text = Titles[i][1]
- local titleValue = Instance.new("BoolValue", plr.Titles)
- titleValue.Name = 'HasTitle'
- titleValue.Value = true
- break
- else
- warn('this player does not meet requirements')
- break
- end
- end
- end
- if action == 'removeTitle' then
- local findValue = plr.Titles:FindFirstChild('HasTitle')
- if not findValue then return end
- if findValue.Value == false then return plr:Kick(ExploitReason) end
- if findValue.Value == true then
- findValue:Destroy()
- end
- end
- end
- Players.PlayerAdded:Connect(function(plr)
- if plr then
- local stats = Instance.new("Folder", plr)
- stats.Name = 'Titles'
- local Coins = Instance.new("IntValue", plr)
- Coins.Name = 'Coins'
- Coins.Value = 10
- end
- plr.CharacterAdded:Connect(function(char)
- titleFunction(plr, 'applyTitle')
- end)
- end)
Add Comment
Please, Sign In to add comment