Advertisement
DarkusBlox

Roblox Studio - Ban Panel (Local Script)

Jul 24th, 2024
1,797
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.24 KB | Source Code | 0 0
  1. -- YT: @darkusblox for a FULL tutorial on how to use the ban panel!!
  2.  
  3. -- Do not edit unless you know what your're doing
  4.  
  5. local player = game.Players.LocalPlayer
  6. local Players = game:GetService("Players")
  7.  
  8. local Template = script.Parent:WaitForChild("Template")
  9. local playerTemp = Template:WaitForChild("PlayerTemp")
  10.  
  11. local BanFrame = script.Parent:WaitForChild("BanFrame")
  12. local PlayersFrame = script.Parent:WaitForChild("PlayersFrame")
  13. local Button = script.Parent:WaitForChild("TextButton")
  14.  
  15. local opened = false
  16.  
  17. local Id_Box = BanFrame:WaitForChild("UserId")
  18. local Duration_Box = BanFrame:WaitForChild("Duration")
  19. local Reason_Box = BanFrame:WaitForChild("Reason")
  20. local PrivReason_Box = BanFrame:WaitForChild("PrivateReason")
  21. local banAltsButton = BanFrame:WaitForChild("AltAccount")
  22. local UniversalButton = BanFrame:WaitForChild("Universal")
  23.  
  24. local BanButton = BanFrame:WaitForChild("BanButton")
  25. local UnbanButton = BanFrame:WaitForChild("UnbanButton")
  26.  
  27. local ResultFrame = script.Parent:WaitForChild("ResultFrame")
  28. local ResultText = ResultFrame:WaitForChild("TextLabel")
  29.  
  30. Button.MouseButton1Up:Connect(function()
  31.     if opened == false then
  32.         opened = true
  33.         BanFrame.Visible = true
  34.         PlayersFrame.Visible = true
  35.         ResultFrame.Visible = true
  36.        
  37.         for _, plr in pairs(Players:GetPlayers()) do
  38.             if plr.Name ~= player.Name then
  39.                 if not PlayersFrame:FindFirstChild(plr.Name) then
  40.                     local newPlayer = playerTemp:Clone()
  41.                     newPlayer.Name = plr.Name
  42.                     newPlayer.Parent = PlayersFrame
  43.                     print(newPlayer.Parent)
  44.                    
  45.                     newPlayer.ImageLabel.Image = Players:GetUserThumbnailAsync(plr.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
  46.                     newPlayer.Display.Text = plr.DisplayName
  47.                     newPlayer.User.Text = "@"..plr.Name
  48.                     newPlayer.Visible = true
  49.                    
  50.                     newPlayer.TextButton.MouseButton1Up:Connect(function()
  51.                         Id_Box.Text = plr.UserId
  52.                     end)
  53.                 end
  54.             end
  55.         end
  56.     elseif opened == true then
  57.         opened = false
  58.         BanFrame.Visible = false
  59.         PlayersFrame.Visible = false
  60.         ResultFrame.Visible = false
  61.        
  62.         for _, plr in pairs(PlayersFrame:GetChildren()) do
  63.             if not plr:IsA("UIListLayout") and not plr:IsA("UIPadding") then
  64.                 if plr then
  65.                     plr:Destroy()
  66.                 end
  67.             end
  68.         end
  69.     end
  70. end)
  71.  
  72. local banAlts = false
  73.  
  74. banAltsButton.MouseButton1Up:Connect(function()
  75.     if banAlts == false then
  76.         banAlts = true
  77.         banAltsButton.BackgroundColor3 = Color3.fromRGB(11, 170, 0)
  78.     else
  79.         banAlts = false
  80.         banAltsButton.BackgroundColor3 = Color3.fromRGB(170, 0, 0)
  81.     end
  82. end)
  83.  
  84. local universalBan = false
  85.  
  86. UniversalButton.MouseButton1Up:Connect(function()
  87.     if universalBan == false then
  88.         universalBan = true
  89.         UniversalButton.BackgroundColor3 = Color3.fromRGB(11, 170, 0)
  90.     else
  91.         universalBan = false
  92.         UniversalButton.BackgroundColor3 = Color3.fromRGB(170, 0, 0)
  93.     end
  94. end)
  95.  
  96. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  97. local banFunc = ReplicatedStorage:FindFirstChild("Ban")
  98. local unbanFunc = ReplicatedStorage:FindFirstChild("Unban")
  99.  
  100. local banDebounce = false
  101.  
  102. BanButton.MouseButton1Up:Connect(function()
  103.     if banDebounce == false then
  104.         banDebounce = true
  105.         local result = banFunc:InvokeServer(tonumber(Id_Box.Text), tonumber(Duration_Box.Text), Reason_Box.Text, PrivReason_Box.Text, banAlts, universalBan)
  106.         if result == true then
  107.             ResultText.Text = "Player banned successfuly!"
  108.             ResultText.TextColor3 = Color3.fromRGB(11, 170, 0)
  109.             wait(2)
  110.             banDebounce = false
  111.             ResultText.Text = ""
  112.         else
  113.             ResultText.Text = "Error, make sure to fill in all boxes!"
  114.             ResultText.TextColor3 = Color3.fromRGB(170, 0, 0)
  115.             wait(2)
  116.             banDebounce = false
  117.             ResultText.Text = ""
  118.         end
  119.     end
  120. end)
  121.  
  122. UnbanButton.MouseButton1Up:Connect(function()
  123.     if banDebounce == false then
  124.         banDebounce = true
  125.         local result = unbanFunc:InvokeServer(tonumber(Id_Box.Text), universalBan)
  126.         if result == true then
  127.             ResultText.Text = "Player unbaneed successfuly!"
  128.             ResultText.TextColor3 = Color3.fromRGB(11, 170, 0)
  129.             wait(2)
  130.             banDebounce = false
  131.             ResultText.Text = ""
  132.         else
  133.             ResultText.Text = "Error, make sure to fill in all boxes!"
  134.             ResultText.TextColor3 = Color3.fromRGB(170, 0, 0)
  135.             wait(2)
  136.             banDebounce = false
  137.             ResultText.Text = ""
  138.         end
  139.     end
  140. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement