Advertisement
RoScripter

Warn Command

Jul 18th, 2020
8,823
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.14 KB | None | 0 0
  1. local GroupId = 1234567 --REPLACE 1234567 WITH YOUR GROUP ID
  2. local MinimumRankToUseCommand = 255 --REPLACE 255 WITH THE MINIMUM RANK ID TO USE THE !WARN COMMAND
  3.  
  4. game.Players.PlayerAdded:Connect(function(Player)
  5.     Player.CharacterAdded:Connect(function(Character)
  6.         local WarningGUI = script.WarningGUI:Clone()
  7.         WarningGUI.Parent = Character.Head
  8.     end)
  9.    
  10.     Player.Chatted:Connect(function(Message)
  11.         local SplitMessage = Message:split(" ")
  12.         if SplitMessage[1] == "!warn" and Player:GetRankInGroup(GroupId) >= MinimumRankToUseCommand then
  13.             local NameOfPlayerToWarn = SplitMessage[2]
  14.             local PlayerToWarn = game.Players:FindFirstChild(NameOfPlayerToWarn)
  15.             local Reason = Message:split(NameOfPlayerToWarn)[2]
  16.            
  17.             local WarningGUI = PlayerToWarn.Character.Head.WarningGUI
  18.             local CurrentWarnings = WarningGUI.Warnings
  19.            
  20.             CurrentWarnings.Value = CurrentWarnings.Value + 1
  21.             WarningGUI.WarningLabel.Text = "W" .. CurrentWarnings.Value .. " - " .. Reason
  22.            
  23.             if CurrentWarnings.Value >= 3 then
  24.                 PlayerToWarn:Kick("You've reached the maximum number of warnings and have been kicked from the server.")
  25.             end
  26.         end
  27.     end)
  28. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement