C-H-4-0-S

Ban / kick gui

Jun 28th, 2023
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.60 KB | None | 0 0
  1. local rs = game.ReplicatedStorage:WaitForChild("AdminPanelRS")
  2. local re = rs:WaitForChild("RE")
  3. local admins = require(rs:WaitForChild("AdminsModule"))
  4.  
  5. local uis = game:GetService("UserInputService")
  6. local ts = game:GetService("TweenService")
  7.  
  8. local panel = script.Parent:WaitForChild("AdminPanel")
  9. panel.Visible = false
  10. local announcement = script.Parent:WaitForChild("AnnouncementsFrame")
  11. announcement.Visible = false
  12.  
  13. local plrId = game.Players.LocalPlayer.UserId
  14.  
  15.  
  16. --Receive announcements
  17. local goalTransparency = announcement.Transparency
  18.  
  19. function createAnnouncement(message)
  20. announcement.AnnouncementText.Text = ""
  21. announcement.AnnouncementText.TextTransparency = 0
  22. announcement.Transparency = 1
  23. announcement.Visible = true
  24.  
  25. local fadeTweenInfo = TweenInfo.new(0.4, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
  26. local fadeInTween = ts:Create(announcement, fadeTweenInfo, {Transparency = goalTransparency})
  27. fadeInTween:Play()
  28. task.wait(0.3)
  29.  
  30. for i = 1, string.len(message) do
  31. announcement.AnnouncementText.Text = string.sub(message, 1, i)
  32. local currentChar = string.sub(message, i, i)
  33. task.wait(currentChar == "\n" and 0.3 or currentChar == " " and 0.04 or 0.02)
  34. end
  35.  
  36. local announcementTime = string.len(message) / 16
  37. task.wait(announcementTime)
  38.  
  39. local fadeOutTween = ts:Create(announcement, fadeTweenInfo, {Transparency = 1})
  40. fadeOutTween:Play()
  41. local fadeTextTween = ts:Create(announcement.AnnouncementText, fadeTweenInfo, {TextTransparency = 1})
  42. fadeTextTween:Play()
  43.  
  44. fadeTextTween.Completed:Wait()
  45. announcement.Visible = false
  46. end
  47.  
  48. re.OnClientEvent:Connect(function(instruction, message)
  49. if instruction == "ANNOUNCE" then
  50. createAnnouncement(message)
  51. end
  52. end)
  53.  
  54.  
  55. --Update list of players in admin panel
  56. local selectPlrFrame = panel.Pages.MainButtonsFrame.ButtonsScroller.SelectPlayerFrame
  57. local scroller = selectPlrFrame.PlayersScroller
  58. local selectedFrame = selectPlrFrame.SelectedPlayerFrame
  59. selectedFrame.Visible = false
  60.  
  61. function updatePlayers()
  62. for i, child in pairs(scroller:GetChildren()) do
  63. if child:IsA("TextButton") then
  64. child:Destroy()
  65. end
  66. end
  67.  
  68. for i, plr in pairs(game.Players:GetPlayers()) do
  69.  
  70. local btn = script.PlayerButton:Clone()
  71.  
  72. local name = plr.Name
  73. btn.PlayerName.Text = name
  74.  
  75. local image = game.Players:GetUserThumbnailAsync(plr.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)
  76. btn.PlayerImage.Image = image
  77.  
  78. btn.MouseButton1Click:Connect(function()
  79.  
  80. selectedFrame.PlayerName.Text = name
  81. selectedFrame.DisplayName.Text = "@" .. plr.DisplayName
  82. selectedFrame.UserId.Text = plr.UserId
  83. selectedFrame.InGame.Text = "Currently in server 🟢"
  84. selectedFrame.PlayerImage.Image = image
  85.  
  86. selectedFrame.Visible = true
  87. end)
  88.  
  89. btn.Parent = scroller
  90. end
  91. end
  92. updatePlayers()
  93. game.Players.PlayerAdded:Connect(updatePlayers)
  94. game.Players.PlayerRemoving:Connect(updatePlayers)
  95.  
  96.  
  97. --If not admin, delete admin panel
  98. if not table.find(admins, plrId) then
  99. panel:Destroy()
  100.  
  101. --If admin, give access to admin panel
  102. else
  103. --Alert user they are an admin
  104. createAnnouncement("You are an admin.\nUse the 'B' key to open the admin panel.")
  105.  
  106. uis.InputBegan:Connect(function(inp, p)
  107. if not p and inp.KeyCode == Enum.KeyCode.B then --Press B on keyboard to open admin panel
  108. panel.Visible = not panel.Visible
  109. end
  110. end)
  111.  
  112. panel.CloseButton.MouseButton1Click:Connect(function() --Close admin panel when button is clicked on
  113. panel.Visible = false
  114. end)
  115.  
  116. selectPlrFrame.UserIdBox.FocusLost:Connect(function() --Search UserIds to select players not in the same server as the admin
  117. local userId = selectPlrFrame.UserIdBox.Text
  118.  
  119. if tonumber(userId) then
  120. local plrInfo = game:GetService("UserService"):GetUserInfosByUserIdsAsync({tonumber(userId)})[1]
  121. if plrInfo then
  122. local username = plrInfo.Username
  123. local displayName = plrInfo.DisplayName
  124. local inServer = game.Players:FindFirstChild(username)
  125. local image = game.Players:GetUserThumbnailAsync(userId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)
  126.  
  127. selectedFrame.PlayerName.Text = username
  128. selectedFrame.DisplayName.Text = "@" .. displayName
  129. selectedFrame.UserId.Text = userId
  130. selectedFrame.InGame.Text = inServer and "Currently in server 🟢" or "Not in server 🔴"
  131. selectedFrame.PlayerImage.Image = image
  132.  
  133. selectedFrame.Visible = true
  134. end
  135. end
  136. end)
  137.  
  138. --Command Bar
  139. panel.CommandBar.FocusLost:Connect(function(enterPressed)
  140. if enterPressed then
  141. re:FireServer("COMMAND BAR", panel.CommandBar.Text)
  142. end
  143. end)
  144.  
  145. local btns = panel.Pages.MainButtonsFrame.ButtonsScroller; btns.Parent.Visible = true
  146. local muteFrame = panel.Pages.MuteFrame; muteFrame.Visible = false
  147. local banFrame = panel.Pages.BanFrame; banFrame.Visible = false
  148. local kickFrame = panel.Pages.KickFrame; kickFrame.Visible = false
  149. local annFrame = panel.Pages.AnnounceFrame; annFrame.Visible = false
  150. local shutFrame = panel.Pages.ShutdownFrame; shutFrame.Visible = false
  151.  
  152. --MODERATION BUTTONS
  153. --Mute Button
  154. btns.ModerationButtons.MuteButton.MouseButton1Click:Connect(function()
  155. if tonumber(selectedFrame.UserId.Text) then
  156. muteFrame.DisplayName.Text = selectedFrame.DisplayName.Text
  157. muteFrame.PlayerName.Text = selectedFrame.PlayerName.Text
  158. muteFrame.PlayerImage.Image = selectedFrame.PlayerImage.Image
  159. muteFrame.Visible = true
  160. btns.Parent.Visible = false
  161. end
  162. end)
  163. muteFrame.BackButton.MouseButton1Click:Connect(function()
  164. btns.Parent.Visible = true
  165. muteFrame.Visible = false
  166. end)
  167. muteFrame.ConfirmButton.MouseButton1Click:Connect(function()
  168. local name = string.gsub(muteFrame.PlayerName.Text, "@", "")
  169. local targetId = game.Players:GetUserIdFromNameAsync(name)
  170. local length = tonumber(muteFrame.MuteLengthBox.Text)
  171. if targetId and length then
  172. btns.Parent.Visible = true
  173. muteFrame.Visible = false
  174. re:FireServer("MUTE", length, targetId)
  175. end
  176. end)
  177.  
  178. --Unmute Button
  179. btns.ModerationButtons.UnmuteButton.MouseButton1Click:Connect(function()
  180. if tonumber(selectedFrame.UserId.Text) then
  181. re:FireServer("UNMUTE", nil, tonumber(selectedFrame.UserId.Text))
  182. end
  183. end)
  184. --Ban Button
  185. btns.ModerationButtons.BanButton.MouseButton1Click:Connect(function()
  186. if tonumber(selectedFrame.UserId.Text) then
  187. banFrame.DisplayName.Text = selectedFrame.DisplayName.Text
  188. banFrame.PlayerName.Text = selectedFrame.PlayerName.Text
  189. banFrame.PlayerImage.Image = selectedFrame.PlayerImage.Image
  190. panel.Pages.BanFrame.Visible = true
  191. btns.Parent.Visible = false
  192. end
  193. end)
  194. banFrame.BackButton.MouseButton1Click:Connect(function()
  195. btns.Parent.Visible = true
  196. banFrame.Visible = false
  197. end)
  198. banFrame.ConfirmButton.MouseButton1Click:Connect(function()
  199. local name = string.gsub(banFrame.PlayerName.Text, "@", "")
  200. local targetId = game.Players:GetUserIdFromNameAsync(name)
  201. local length = tonumber(banFrame.BanLengthBox.Text)
  202. local compiled = {length, banFrame.ReasonBox.Text}
  203. if targetId and length then
  204. btns.Parent.Visible = true
  205. banFrame.Visible = false
  206. re:FireServer("BAN", compiled, targetId)
  207. end
  208. end)
  209. --Unban Button
  210. btns.ModerationButtons.UnbanButton.MouseButton1Click:Connect(function()
  211. if tonumber(selectedFrame.UserId.Text) then
  212. re:FireServer("UNBAN", nil, tonumber(selectedFrame.UserId.Text))
  213. end
  214. end)
  215. --Kick Button
  216. btns.ModerationButtons.KickButton.MouseButton1Click:Connect(function()
  217. if tonumber(selectedFrame.UserId.Text) then
  218. kickFrame.DisplayName.Text = selectedFrame.DisplayName.Text
  219. kickFrame.PlayerName.Text = selectedFrame.PlayerName.Text
  220. kickFrame.PlayerImage.Image = selectedFrame.PlayerImage.Image
  221. panel.Pages.KickFrame.Visible = true
  222. btns.Parent.Visible = false
  223. end
  224. end)
  225. kickFrame.BackButton.MouseButton1Click:Connect(function()
  226. btns.Parent.Visible = true
  227. kickFrame.Visible = false
  228. end)
  229. kickFrame.ConfirmButton.MouseButton1Click:Connect(function()
  230. local name = string.gsub(kickFrame.PlayerName.Text, "@", "")
  231. local targetId = game.Players:GetUserIdFromNameAsync(name)
  232. local reason = kickFrame.ReasonBox.Text
  233. if targetId then
  234. btns.Parent.Visible = true
  235. kickFrame.Visible = false
  236. re:FireServer("KICK", reason, targetId)
  237. end
  238. end)
  239.  
  240. --CHARACTER BUTTONS
  241. --Go To Button
  242. btns.CharacterButtons.GoToButton.MouseButton1Click:Connect(function()
  243. if tonumber(selectedFrame.UserId.Text) then
  244. re:FireServer("GO TO", nil, tonumber(selectedFrame.UserId.Text))
  245. end
  246. end)
  247. --Bring Button
  248. btns.CharacterButtons.BringButton.MouseButton1Click:Connect(function()
  249. if tonumber(selectedFrame.UserId.Text) then
  250. re:FireServer("BRING", nil, tonumber(selectedFrame.UserId.Text))
  251. end
  252. end)
  253. --Freeze Button
  254. btns.CharacterButtons.FreezeButton.MouseButton1Click:Connect(function()
  255. if tonumber(selectedFrame.UserId.Text) then
  256. re:FireServer("FREEZE", nil, tonumber(selectedFrame.UserId.Text))
  257. end
  258. end)
  259. --Unfreeze Button
  260. btns.CharacterButtons.UnfreezeButton.MouseButton1Click:Connect(function()
  261. if tonumber(selectedFrame.UserId.Text) then
  262. re:FireServer("UNFREEZE", nil, tonumber(selectedFrame.UserId.Text))
  263. end
  264. end)
  265. --Speed Input Box
  266. btns.CharacterButtons.WalkSpeedBox.FocusLost:Connect(function(enterPressed)
  267. if enterPressed and tonumber(selectedFrame.UserId.Text) then
  268. re:FireServer("SPEED", tonumber(btns.CharacterButtons.WalkSpeedBox.Text), tonumber(selectedFrame.UserId.Text))
  269. end
  270. end)
  271. --Jump Input Box
  272. btns.CharacterButtons.JumpHeightBox.FocusLost:Connect(function(enterPressed)
  273. if enterPressed and tonumber(selectedFrame.UserId.Text) then
  274. re:FireServer("JUMP", tonumber(btns.CharacterButtons.JumpHeightBox.Text), tonumber(selectedFrame.UserId.Text))
  275. end
  276. end)
  277. --Health Input Box
  278. btns.CharacterButtons.HealthBox.FocusLost:Connect(function(enterPressed)
  279. if enterPressed and tonumber(selectedFrame.UserId.Text) then
  280. re:FireServer("HEALTH", tonumber(btns.CharacterButtons.HealthBox.Text), tonumber(selectedFrame.UserId.Text))
  281. end
  282. end)
  283.  
  284. --SYSTEM BUTTONS
  285. --Announce Button
  286. btns.SystemButtons.AnnounceButton.MouseButton1Click:Connect(function()
  287. panel.Pages.AnnounceFrame.Visible = true
  288. btns.Parent.Visible = false
  289. end)
  290. annFrame.BackButton.MouseButton1Click:Connect(function()
  291. btns.Parent.Visible = true
  292. annFrame.Visible = false
  293. end)
  294. local server = annFrame.ServerButton
  295. local global = annFrame.GlobalButton
  296. server.CircleBackground.CircleFill.Visible = true
  297. server.MouseButton1Click:Connect(function()
  298. global.CircleBackground.CircleFill.Visible = false
  299. server.CircleBackground.CircleFill.Visible = true
  300. end)
  301. global.CircleBackground.CircleFill.Visible = false
  302. global.MouseButton1Click:Connect(function()
  303. server.CircleBackground.CircleFill.Visible = false
  304. global.CircleBackground.CircleFill.Visible = true
  305. end)
  306. annFrame.ConfirmButton.MouseButton1Click:Connect(function()
  307. local message = annFrame.AnnouncementBox.Text
  308. local messageGlobal = global.CircleBackground.CircleFill.Visible and "GLOBAL" or "SERVER"
  309. if string.len(message) > 0 then
  310. btns.Parent.Visible = true
  311. annFrame.Visible = false
  312. re:FireServer("ANNOUNCE", message, messageGlobal)
  313. end
  314. end)
  315. --Shutdown Button
  316. btns.SystemButtons.ShutdownButton.MouseButton1Click:Connect(function()
  317. panel.Pages.ShutdownFrame.Visible = true
  318. btns.Parent.Visible = false
  319. end)
  320. shutFrame.BackButton.MouseButton1Click:Connect(function()
  321. btns.Parent.Visible = true
  322. shutFrame.Visible = false
  323. end)
  324. shutFrame.ConfirmButton.MouseButton1Click:Connect(function()
  325. btns.Parent.Visible = true
  326. shutFrame.Visible = false
  327. re:FireServer("SHUT DOWN")
  328. end)
  329. end
Add Comment
Please, Sign In to add comment