Bacon_Script

Npc Controller Script!

Jul 9th, 2023
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 5.92 KB | Writing | 0 0
  1. --[[
  2. Hold LeftControl and Click an npc to control
  3.  
  4. Press Quote to return to your player
  5.  
  6. Hold LeftShift and press a Numpad key to save your current npc
  7.  
  8. Hold LeftControl and press a Numpad key to control the saved npc
  9. ]]
  10.  
  11. spawn(function()
  12.   while wait() do
  13.     game.Players.LocalPlayer.MaximumSimulationRadius = math.huge;
  14.     setsimulationradius(math.huge);
  15.   end
  16. end)
  17.  
  18. local OGPN = game.Players.LocalPlayer.Name
  19. local Player = game.Players.LocalPlayer
  20. local Mouse = Player:GetMouse()
  21.  
  22. function Ctrl(NPC)
  23.   Char = NPC
  24.   Player.Character = Char
  25.   workspace.CurrentCamera.CameraSubject = Char
  26.   Char.Animate.Disabled = true
  27.  wait(0.1)
  28.   Char.Animate.Disabled = false
  29. end
  30.  
  31. Mouse.Button1Down:connect(function()
  32.   if game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftControl) and Mouse.Target ~= nil and Mouse.Target.Parent.Name ~= "Workspace" and Mouse.Target.Parent:FindFirstChildOfClass("Humanoid") ~= nil then
  33.     Char = Mouse.Target.Parent
  34.     Player.Character = Mouse.Target.Parent
  35.     workspace.CurrentCamera.CameraSubject = Char
  36.     Char.Animate.Disabled = true
  37.    wait(0.1)
  38.     Char.Animate.Disabled = false
  39.   end
  40. end)
  41.  
  42. Mouse.KeyDown:connect(function()
  43.   if game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.KeypadOne) and game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftShift) and not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftControl) then
  44.     a = Char
  45.   elseif game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.KeypadTwo) and game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftShift) and not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftControl) then
  46.     b = Char
  47.   elseif game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.KeypadThree) and game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftShift) and not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftControl) then
  48.     c = Char
  49.   elseif game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.KeypadFour) and game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftShift) and not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftControl) then
  50.     d = Char
  51.   elseif game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.KeypadFive) and game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftShift) and not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftControl) then
  52.     e = Char
  53.   elseif game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.KeypadSix) and game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftShift) and not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftControl) then
  54.     f = Char
  55.   elseif game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.KeypadSeven) and game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftShift) and not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftControl) then
  56.     g = Char
  57.   elseif game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.KeypadEight) and game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftShift) and not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftControl) then
  58.     h = Char
  59.   elseif game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.KeypadNine) and game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftShift) and not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftControl) then
  60.     i = Char
  61.   end
  62. end)
  63.  
  64. Mouse.KeyDown:connect(function()
  65.   if game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.Quote) then
  66.     for i,v in pairs(game.Workspace:GetDescendants()) do
  67.       if v.Name == OGPN and v.ClassName == 'Model' then
  68.         Ctrl(v)
  69.       end
  70.     end
  71.   elseif game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.KeypadOne) and game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftControl) and not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftShift) then
  72.     Ctrl(a)
  73.   elseif game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.KeypadTwo) and game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftControl) and not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftShift) then
  74.     Ctrl(b)
  75.   elseif game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.KeypadThree) and game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftControl) and not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftShift) then
  76.     Ctrl(c)
  77.   elseif game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.KeypadFour) and game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftControl) and not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftShift) then
  78.     Ctrl(d)
  79.   elseif game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.KeypadFive) and game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftControl) and not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftShift) then
  80.     Ctrl(e)
  81.   elseif game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.KeypadSix) and game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftControl) and not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftShift) then
  82.     Ctrl(f)
  83.   elseif game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.KeypadSeven) and game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftControl) and not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftShift) then
  84.     Ctrl(g)
  85.   elseif game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.KeypadEight) and game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftControl) and not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftShift) then
  86.     Ctrl(h)
  87.   elseif game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.KeypadNine) and game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftControl) and not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftShift) then
  88.     Ctrl(i)
  89.   end
  90. end)
Tags: #script
Add Comment
Please, Sign In to add comment