Advertisement
dubleeyrblxx

Speed and TP custom command -- Roblox

Jun 1st, 2022
1,066
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.17 KB | None | 0 0
  1. -- put in ServerScriptService
  2. -- credits to alvinblox
  3.  
  4. local commands = {}
  5.  
  6. local admins = {
  7.     "Dubleey" -- put your name here
  8. }
  9.  
  10. local prefix = ">" -- put your prefix here
  11.  
  12. local function findPlayer(name)
  13.    
  14.    
  15.     for i, player in pairs(game.Players:GetPlayers()) do
  16.         if string.lower(player.Name) == name then
  17.             return player
  18.         end
  19.     end
  20.    
  21.     return nil
  22.    
  23. end
  24.  
  25. local function isAdmin(player)
  26.     for _, v in pairs(admins) do
  27.         if v == player.Name then
  28.             return true
  29.         end
  30.     end
  31.    
  32.     return false
  33. end
  34.  
  35. commands.zoom = function(sender, arguments) -- this is tp command, put whatever you wanna name it after commands.
  36.    
  37.     print("tp function fired by"..sender.Name)
  38.    
  39.     for _, playerName in pairs(arguments) do
  40.         print(playerName)
  41.     end
  42.    
  43.     local playerToTeleportName = arguments[1]
  44.     local playerToTeleportToName = arguments[2]
  45.    
  46.     if playerToTeleportName and playerToTeleportToName then
  47.         local plrToTP = findPlayer(playerToTeleportName)
  48.         local plrToTPTo = findPlayer(playerToTeleportToName)
  49.        
  50.         if plrToTP and plrToTPTo then
  51.             plrToTP.Character.HumanoidRootPart.CFrame = plrToTPTo.Character.HumanoidRootPart.CFrame
  52.             print("succysessy")
  53.         end
  54.     end
  55.    
  56. end
  57.  
  58. commands.speed = function(sender, arguments) -- this is speed command, put whatever you wanna name it after commands
  59.    
  60.     print("speedcmd done by"..sender.Name)
  61.    
  62.     local playerToGiveSpeedTo = arguments[1]
  63.     local amountOfSpeedToGive = arguments[2]
  64.    
  65.     if playerToGiveSpeedTo then
  66.         local plr = findPlayer(playerToGiveSpeedTo)
  67.        
  68.         if plr then
  69.             plr.Character.Humanoid.WalkSpeed = tonumber(amountOfSpeedToGive)
  70.         end
  71.     end
  72. end
  73.  
  74. game.Players.PlayerAdded:Connect(function(player)
  75.     player.Chatted:Connect(function(message,recipient)
  76.         if isAdmin(player) then
  77.             message = string.lower(message)
  78.            
  79.             local splitString = message:split(" ")
  80.            
  81.             local arrowCommand = splitString[1]
  82.            
  83.             local cmd = arrowCommand:split(prefix)
  84.            
  85.             local cmdName = cmd[2]
  86.            
  87.             if commands[cmdName] then
  88.                
  89.                 local arguments = {}
  90.                
  91.                 for i = 2, #splitString, 1 do
  92.                     table.insert(arguments,splitString[i])
  93.                 end
  94.                
  95.                 commands[cmdName](player,arguments)
  96.            
  97.             end
  98.         end
  99.     end)
  100. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement