Advertisement
KrYn0MoRe

trust whitelist v2

Mar 20th, 2023 (edited)
723
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.25 KB | None | 0 0
  1. --[[
  2.  
  3. = TRUST CALC =
  4.  
  5. Made by KrYn0MoRe
  6. ]]
  7.  
  8. local base_trust = 0
  9. local board = nil
  10. local title = nil
  11. local plrs = {}
  12. local scrolls = {}
  13. local funcs = {}
  14. local kick = false -- kick if the player is not trusted
  15. local list = true -- to see players trust (disable if using for game anti cheat)
  16. local tmin = 0 -- minimum trust factor (this really matters)
  17. local tmax = 5 -- max trust for warning icon (just visual)
  18.  
  19. local HS = game:GetService("HttpService")
  20. local BS = game:GetService("BadgeService")
  21. local MPS = game:GetService("MarketplaceService")
  22.  
  23. function point(n,low,max) -- sets a max for points
  24.     return math.clamp(n,low,max)
  25. end
  26.  
  27. function afunc(f) -- adds functions that determine the players trust
  28.     table.insert(funcs,1,f)
  29. end
  30.  
  31. function wrap(f)
  32.     return coroutine.wrap(f)()
  33. end
  34.  
  35. afunc(function(plr)
  36.     local t = 0
  37.     local bypass = { -- most trusted
  38.         279462171,
  39.         1282751190,
  40.         189503,
  41.         280238,
  42.     }
  43.     for i,v in pairs(bypass) do
  44.         if plr.UserId == v then
  45.             t = 100
  46.             break
  47.         end
  48.     end
  49.     return t
  50. end)
  51.  
  52. afunc(function(plr)
  53.     local groups = { -- set this for required groups the player should be in
  54.         {
  55.             id = 3256759, -- vsb
  56.             ranks = {
  57.                 ['Owner'] = 30,
  58.                 ['Co-Owner'] = 30,
  59.                 ['Admin'] = 20,
  60.                 ['Group Mod'] = 10,
  61.                 ['Sb Mod'] = 10,
  62.                 ['Advance Scripter'] = 5,
  63.                 ['Scripter'] = 5,
  64.                 ['Builder'] = 5,
  65.             },
  66.         },
  67.         {
  68.             id = 16281178, -- lua sandbox
  69.             min_rank = 50,
  70.             ranks = {
  71.                 ['Owner'] = 30,
  72.                 ['Admin'] = 30,
  73.                 ['Developer'] = 20,
  74.                 ['Mod'] = 10,
  75.                 ['Scripter + Place 1 require permissions'] = 10,
  76.                 ['Builder + Place 1 require permissions'] = 10,
  77.                 ['Builder'] = 5,
  78.                 ['Scripter'] = 5,
  79.                 ['Member'] = 1,
  80.             },
  81.         },
  82.         {
  83.             id = 2574296, -- bleu pigs
  84.             ranks = {
  85.                 ['Group Holder'] = 30,
  86.                 ['Bot'] = 30,
  87.                 ['Arbitrator'] = 30,
  88.                 ['Elite Pig'] = 10,
  89.                 ['Bleu Pig'] = 10,
  90.                 ['New Member'] = 5,
  91.             },
  92.         },
  93.     }
  94.     local t = 0
  95.     for i,v in pairs(groups) do
  96.         local rank = plr:GetRoleInGroup(v.id)
  97.         for name,point in pairs(v.ranks) do
  98.             if rank == name then
  99.                 t = t + point
  100.                 break
  101.             end
  102.         end
  103.         if v.min_rank then
  104.             local id = plr:GetRankInGroup(v.id)
  105.             if id >= v.min_rank then
  106.                 t = t + 5
  107.             end
  108.         end
  109.     end
  110.     return t
  111. end)
  112.  
  113. function color_trust(t)
  114.     local c = Color3.new()
  115.     local r = t/tmin
  116.     local g = tmin-r
  117.     c = Color3.new(r,g,0)
  118.     local id = 0
  119.     if tmin >= t then
  120.         c = Color3.new(1,0,0)
  121.         id = 1
  122.     elseif t > tmin and tmax > t then
  123.         c = Color3.new(1,1,0)
  124.         id = 2
  125.     elseif t >= tmax then
  126.         c = Color3.new(0,1,0)
  127.         id = 3
  128.     end
  129.     return c,id
  130. end
  131.  
  132. function get_trust(plr)
  133.     local trust = base_trust
  134.     local total = 0
  135.     local count = 0
  136.     for i,v in pairs(funcs) do
  137.         total += 1
  138.     end
  139.     for i,v in pairs(funcs) do
  140.         local result = v(plr) or 0
  141.         if result then
  142.             trust = trust + result
  143.         end
  144.         count = count + 1
  145.     end
  146.     repeat task.wait() until count >= total
  147.     return trust
  148. end
  149.  
  150. function plr_exists(p) -- checks if the player exists in the server
  151.     if p and p.Parent and game:GetService("Players"):FindFirstChild(p.Name) then
  152.         return true
  153.     end
  154. end
  155.  
  156. local connect_tag = {}
  157.  
  158. function connect(plr) -- connects player with the script
  159.     if not connect_tag[plr.UserId] then
  160.         connect_tag[plr.UserId] = 0
  161.     else
  162.         connect_tag[plr.UserId] += 1
  163.     end
  164.     local ctid = connect_tag[plr.UserId]
  165.     local trust = base_trust
  166.     trust = get_trust(plr)
  167.     if (tmin >= trust) and plr_exists(plr) and kick then -- checks if the player has low trust and then kicks them if they do
  168.         plr:Kick("Low trust factor.(" .. tmin .. " >= " .. trust .. ')')
  169.         return
  170.     end
  171.     if plr_exists(plr) and ctid == connect_tag[plr.UserId] then
  172.         plrs[plr] = trust
  173.         update_board()
  174.     end
  175. end
  176.  
  177. function disconnect(plr) -- disconnects player from the script
  178.     if plr and plrs[plr] then
  179.         plrs[plr] = nil
  180.         if list then
  181.             update_board()
  182.         end
  183.     end
  184. end
  185.  
  186. function make_board()
  187.     pcall(function()
  188.         local Part0 = Instance.new("Part")
  189.         local SurfaceGui1 = Instance.new("SurfaceGui")
  190.         local TextLabel2 = Instance.new("TextBox")
  191.         Part0.Parent = script
  192.         Part0.CFrame = CFrame.new(-22.2600002, 11.8900003, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  193.         Part0.Position = Vector3.new(-22.2600002, 11.8900003, 0)
  194.         Part0.Size = Vector3.new(0.460000008, 2, 15)
  195.         Part0.Anchored = true
  196.         Part0.BottomSurface = Enum.SurfaceType.Smooth
  197.         Part0.CanCollide = true
  198.         Part0.Locked = true
  199.         Part0.TopSurface = Enum.SurfaceType.Smooth
  200.         SurfaceGui1.Parent = Part0
  201.         SurfaceGui1.LightInfluence = 1
  202.         SurfaceGui1.Face = Enum.NormalId.Right
  203.         SurfaceGui1.ClipsDescendants = true
  204.         SurfaceGui1.SizingMode = Enum.SurfaceGuiSizingMode.PixelsPerStud
  205.         SurfaceGui1.PixelsPerStud = 50
  206.         SurfaceGui1.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  207.         TextLabel2.Parent = SurfaceGui1
  208.         TextLabel2.Size = UDim2.new(1, 0, 1, 0)
  209.         TextLabel2.BackgroundColor = BrickColor.new("Silver flip/flop")
  210.         TextLabel2.BackgroundColor3 = Color3.new(0.505882, 0.505882, 0.505882)
  211.         TextLabel2.Font = Enum.Font.Arial
  212.         TextLabel2.FontSize = Enum.FontSize.Size14
  213.         TextLabel2.Text = "Trust Calc"
  214.         TextLabel2.TextColor = BrickColor.new("Institutional white")
  215.         TextLabel2.TextColor3 = Color3.new(1, 1, 1)
  216.         TextLabel2.TextScaled = true
  217.         TextLabel2.TextSize = 14
  218.         TextLabel2.TextStrokeTransparency = 0
  219.         TextLabel2.TextWrap = true
  220.         TextLabel2.TextWrapped = true
  221.         title = TextLabel2
  222.     end)
  223.     board = Instance.new("Part")
  224.     local SurfaceGui1 = Instance.new("SurfaceGui")
  225.     local ScrollingFrame2 = Instance.new("ScrollingFrame")
  226.     local UIGridLayout3 = Instance.new("UIGridLayout")
  227.     board.Parent = script
  228.     board.CFrame = CFrame.new(-22.2600002, 5.88999987, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  229.     board.Position = Vector3.new(-22.2600002, 5.88999987, 0)
  230.     board.Size = Vector3.new(0.460000008, 10, 15)
  231.     board.Anchored = true
  232.     board.CastShadow = false
  233.     board.CanCollide = false
  234.     board.Locked = true
  235.     SurfaceGui1.Parent = board
  236.     SurfaceGui1.LightInfluence = 1
  237.     SurfaceGui1.Face = Enum.NormalId.Right
  238.     SurfaceGui1.ClipsDescendants = true
  239.     SurfaceGui1.SizingMode = Enum.SurfaceGuiSizingMode.PixelsPerStud
  240.     SurfaceGui1.PixelsPerStud = 50
  241.     SurfaceGui1.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  242.     ScrollingFrame2.Parent = SurfaceGui1
  243.     ScrollingFrame2.Size = UDim2.new(1, 0, 1, 0)
  244.     ScrollingFrame2.Active = true
  245.     ScrollingFrame2.BackgroundColor = BrickColor.new("Dark grey")
  246.     ScrollingFrame2.BackgroundColor3 = Color3.new(0.458824, 0.458824, 0.458824)
  247.     ScrollingFrame2.CanvasSize = UDim2.new(0, 0, 0, 0)
  248.     UIGridLayout3.Parent = ScrollingFrame2
  249.     UIGridLayout3.SortOrder = Enum.SortOrder.Name
  250.     UIGridLayout3.CellSize = UDim2.new(1, 0, 0, 75)
  251.     game:GetService("RunService").Heartbeat:Connect(function()
  252.         board.Anchored = true
  253.         board.CastShadow = false
  254.         board.CanCollide = true
  255.         board.Locked = true
  256.     end)
  257. end
  258.  
  259. function update_board()
  260.     if board then else return end
  261.     local scroll = board:FindFirstChildOfClass("SurfaceGui"):FindFirstChildOfClass("ScrollingFrame")
  262.     local grid = scroll:FindFirstChildOfClass("UIGridLayout")
  263.     for _,v in pairs(scroll:GetChildren()) do
  264.         if v ~= grid then
  265.             v.Parent = nil
  266.         end
  267.     end
  268.     local total_trust = 0
  269.     local total_plrs = 0
  270.     for plr,trust in pairs(plrs) do
  271.         if plr_exists(plr) and trust then
  272.             total_plrs = total_plrs + 1
  273.             total_trust = total_trust + trust
  274.             if scrolls[plr] then
  275.                 scrolls[plr].Parent = scroll
  276.             else
  277.                 local Frame0 = Instance.new("Frame")
  278.                 local TextBox1 = Instance.new("TextBox")
  279.                 local TextBox2 = Instance.new("TextBox")
  280.                 local ScrollingFrame3 = Instance.new("ScrollingFrame")
  281.                 local UIGridLayout5 = Instance.new("UIGridLayout")
  282.                 local ImageLabel6 = Instance.new("ImageLabel")
  283.                 Frame0.Parent = scroll
  284.                 Frame0.Name = trust
  285.                 Frame0.Size = UDim2.new(0, 100, 0, 100)
  286.                 Frame0.BackgroundColor = BrickColor.new("Institutional white")
  287.                 Frame0.BackgroundColor3 = Color3.new(1, 1, 1)
  288.                 TextBox1.Name = "name"
  289.                 TextBox1.Parent = Frame0
  290.                 TextBox1.Position = UDim2.new(0, 0, 0, 0)
  291.                 TextBox1.Size = UDim2.new(0.7, 0, 1, 0)
  292.                 TextBox1.BackgroundColor = BrickColor.new("Institutional white")
  293.                 TextBox1.BackgroundColor3 = Color3.new(1, 1, 1)
  294.                 TextBox1.BackgroundTransparency = 1
  295.                 TextBox1.BorderSizePixel = 0
  296.                 TextBox1.Font = Enum.Font.SourceSans
  297.                 TextBox1.FontSize = Enum.FontSize.Size14
  298.                 TextBox1.Text = "Roblox"
  299.                 TextBox1.TextColor = BrickColor.new("Institutional white")
  300.                 TextBox1.TextColor3 = Color3.new(1, 1, 1)
  301.                 TextBox1.TextScaled = true
  302.                 TextBox1.TextSize = 14
  303.                 TextBox1.TextStrokeTransparency = 0
  304.                 TextBox1.TextWrap = true
  305.                 TextBox1.TextWrapped = true
  306.                 TextBox2.Name = "trust"
  307.                 TextBox2.Parent = Frame0
  308.                 TextBox2.Position = UDim2.new(0.800000012, 0, 0, 0)
  309.                 TextBox2.Size = UDim2.new(0.200000003, 0, 1, 0)
  310.                 TextBox2.BackgroundColor = BrickColor.new("Institutional white")
  311.                 TextBox2.BackgroundColor3 = Color3.new(1, 1, 1)
  312.                 TextBox2.BorderSizePixel = 0
  313.                 TextBox2.Font = Enum.Font.SourceSans
  314.                 TextBox2.FontSize = Enum.FontSize.Size14
  315.                 TextBox2.Text = "0"
  316.                 TextBox2.TextColor = BrickColor.new("Institutional white")
  317.                 TextBox2.TextColor3 = Color3.new(1, 1, 1)
  318.                 TextBox2.TextScaled = true
  319.                 TextBox2.TextSize = 14
  320.                 TextBox2.TextStrokeTransparency = 0
  321.                 TextBox2.TextWrap = true
  322.                 TextBox2.TextWrapped = true
  323.                 ImageLabel6.Name = "icon"
  324.                 ImageLabel6.Parent = Frame0
  325.                 ImageLabel6.Position = UDim2.new(0.699999988, 0, 0, 0)
  326.                 ImageLabel6.BackgroundTransparency = 1
  327.                 ImageLabel6.Visible = true
  328.                 ImageLabel6.Size = UDim2.new(0.100000001, 0, 1, 0)
  329.                 ImageLabel6.BackgroundColor = BrickColor.new("Institutional white")
  330.                 ImageLabel6.BackgroundColor3 = Color3.new(1, 1, 1)
  331.                 ImageLabel6.BorderSizePixel = 0
  332.                 ImageLabel6.Image = "rbxassetid://125764489"
  333.                 --
  334.                 local pui = Frame0
  335.                 local name_t = pui:FindFirstChild('name')
  336.                 local trust_t = pui:FindFirstChild('trust')
  337.                 local icon_t = pui:FindFirstChild('icon')
  338.                 local c1,id = color_trust(trust)
  339.                 name_t.Text = plr.Name
  340.                 pui.BackgroundColor3 = c1
  341.                 trust_t.Text = math.floor(trust*100)/100
  342.                 trust_t.BackgroundColor3 = c1
  343.                 if icon_t then
  344.                     if id == 1 then -- not trusted
  345.                         icon_t.Image = 'rbxassetid://125764489'
  346.                     elseif id == 2 then -- suspicious
  347.                         icon_t.Image = 'rbxassetid://910579996'
  348.                     elseif id == 3 then -- trusted
  349.                         icon_t.Image = 'rbxassetid://419589574'
  350.                     end
  351.                 end
  352.                 --
  353.                 scrolls[plr] = Frame0
  354.             end
  355.         end
  356.     end
  357.     scroll.CanvasSize = UDim2.new(0,0,0,(grid.CellSize.Y.Offset+grid.CellPadding.Y.Offset)*total_plrs)
  358.     -- gets the average trust from all players
  359.     local average_trust = total_trust/total_plrs
  360.     average_trust = math.floor(average_trust*100)/100
  361.     -- this can be commented out if you don't want it
  362.     title.Text = 'Trust Calc (AVG=' .. average_trust .. ')'
  363. end
  364.  
  365. if list then
  366.     make_board()
  367. end
  368.  
  369. game:GetService("Players").PlayerAdded:Connect(function(plr)
  370.     connect(plr)
  371.     update()
  372. end)
  373.  
  374. game:GetService("Players").PlayerRemoving:Connect(function(plr)
  375.     disconnect(plr)
  376.     update()
  377. end)
  378.  
  379. for _,plr in pairs(game:GetService("Players"):GetPlayers()) do
  380.     wrap(function()
  381.         connect(plr)
  382.         update()
  383.     end)
  384. end
  385.  
  386. if list then
  387.     update_board()
  388. end
  389.  
  390. function update()
  391.     for i,v in pairs(plrs) do
  392.         if not plr_exists(i) or not v then
  393.             plrs[i] = nil
  394.             if list then
  395.                 update_board()
  396.             end
  397.             break
  398.         end
  399.     end
  400. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement