Advertisement
HowToRoblox

CommandScript

Oct 22nd, 2019
2,270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.75 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2.  
  3. local command1 = "!kill"
  4. local command2 = "!lasergun"
  5.  
  6. function onChatted(chat, recipient, speaker)
  7.    
  8.     local name = speaker.Name
  9.     chat = string.lower(chat)
  10.    
  11.     if (chat == command1) then
  12.        
  13.         local player = Players:FindFirstChild(name)
  14.        
  15.         local humanoid = player.Character.Humanoid
  16.        
  17.         if humanoid then
  18.             humanoid.Health = 0
  19.         end
  20.     end
  21.  
  22.    
  23.     if (chat == command2) then
  24.        
  25.         local player = Players:FindFirstChild(name)
  26.        
  27.         game.ServerStorage.Gun:clone().Parent = player:WaitForChild("Backpack")
  28.     end
  29. end
  30.  
  31.  
  32. function onPlayerEntered(Player)
  33.     Player.Chatted:connect(function(chat, recipient) onChatted(chat, recipient, Player) end)
  34. end
  35.  
  36.  
  37. game.Players.PlayerAdded:connect(onPlayerEntered)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement