Advertisement
RoScripter

Server Lock GUI

Aug 16th, 2020 (edited)
7,053
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.70 KB | None | 0 0
  1. local GroupId = 12345 --REPLACE 12345 WITH YOUR GROUP ID
  2. local MinimumRankToUseCommands = 254 --REPLACE 254 WITH THE MINIMUM RANK ID TO USE THE SLOCK AND UNSLOCK COMMANDS
  3. local MinimumRankToJoinSlocked = 10 --REPLACE 10 WITH THE MINIMUM RANK ID PLAYERS HAVE TO BE IN ORDER TO JOIN WHEN THE SERVER IS LOCKED
  4. local ServerLockMessage = "The server is locked! Please try joining again later." --REPLACE THE TEXT INSIDE OF THE "" WITH YOUR SERVER LOCK MESSAGE
  5.  
  6. local ServerLocked = false
  7.  
  8. game.Players.PlayerAdded:Connect(function(Player)
  9.     Player.Chatted:Connect(function(Message)
  10.         if Player:GetRankInGroup(GroupId) >= MinimumRankToUseCommands then
  11.             if Message == "!slock" then
  12.                 ServerLocked = true
  13.                
  14.                 local Players = game.Players:GetPlayers()
  15.                
  16.                 for i = 1, #Players do
  17.                     local CurrentPlayer = Players[i]
  18.                     local ServerLockMessage = Player.PlayerGui.ServerLockGUI.ServerLockMessage
  19.                    
  20.                     ServerLockMessage.Visible = true
  21.                     ServerLockMessage.Text = "Server locked for ranks " .. MinimumRankToJoinSlocked .. " and lower."
  22.                     wait(5)
  23.                     ServerLockMessage.Visible = false
  24.                 end
  25.                
  26.             elseif Message == "!unslock" then
  27.                 ServerLocked = false
  28.                
  29.                 local Players = game.Players:GetPlayers()
  30.                
  31.                 for i = 1, #Players do
  32.                     local CurrentPlayer = Players[i]
  33.                     local ServerLockMessage = Player.PlayerGui.ServerLockGUI.ServerLockMessage
  34.                    
  35.                     ServerLockMessage.Visible = true
  36.                     ServerLockMessage.Text = "Server Unlocked"
  37.                     wait(5)
  38.                     ServerLockMessage.Visible = false
  39.                 end
  40.             end
  41.         end
  42.     end)
  43.    
  44.     if ServerLocked == true then
  45.         if Player:GetRankInGroup(GroupId) < MinimumRankToJoinSlocked then
  46.             Player:Kick(ServerLockMessage)
  47.         end
  48.     end
  49. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement