Advertisement
zXzGamePROzXz

Kick

Mar 23rd, 2019
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local Admin = "Guest537561"
  2.  
  3. local Players = Game:GetService("Players") -- Defining Players Service using a variable.
  4.  
  5. Players.PlayerAdded:connect(function(Player) -- Event and function when a player has joined.
  6. if Player.Name == Admin then -- Checking if the player is the admin.
  7. Player.Chatted:connect(function(Message) -- Event and function when the admin chats.
  8. if Message ~= nil then --Checking if the message is not nil with the if statement. (The message is nil when teamchat is used.
  9. if string.lower(string.sub(Message, 1, 4)) == "kick" then --Checking if the kick command is used. string.sub is used to get several characters of the string, in this case the first four. string.lower is used to convert the string to a lowercase string. Saying KICK or Kick instead of kick would work as well.
  10. local Target = Players:FindFirstChild(string.sub(Message, 6)) -- Defining the target using a variable. string.sub is this time used to get all of the characters behind "kick ".
  11. if Target ~= nil then -- Checking if the target is found using an if statement.
  12. Target:Kick() --Removing the target from the game using the :Kick() method on the player object.
  13. end -- Closing the if statement at line eleven.
  14. end -- Closing the if statement at line nine.
  15. end -- Closing the if statement at line eight.
  16. end) -- Closing function and event at line seven.
  17. end -- Closing the if statement at line six.
  18. end) -- Closing function and event at line five.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement