CriShoux

Framed

Jan 16th, 2021 (edited)
1,295
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local Players = game:GetService('Players');
  2.  
  3. local X_KEYCODE = Enum.KeyCode.X;
  4. local V_KEYCODE = Enum.KeyCode.V;
  5. local RAY = Ray.new(Vector3.new(), Vector3.new());
  6.  
  7. local localPlayer = Players.LocalPlayer;
  8. local char;
  9. local rootPart;
  10.  
  11. local shootEvent = workspace.Events.Shoot;
  12.  
  13. local function CharacterAdded(character)
  14.     if not character then return; end;
  15.     char = character;
  16.     rootPart = char:WaitForChild('HumanoidRootPart');
  17. end;
  18.  
  19. local function GetTargetFaceImage()
  20.     local suc, targetFaceImage = pcall(function()
  21.         return localPlayer.Backpack["Check Target"].PistolPart.SurfaceGui.Phone.FaceColor.FaceImage.Image:match('%d+');
  22.     end);
  23.     return suc and targetFaceImage;
  24. end;
  25.  
  26. local function GetTargetCharacter()
  27.     local targetFaceImage = GetTargetFaceImage();
  28.     if not targetFaceImage then return; end;
  29.     for i, v in next, Players:GetPlayers() do
  30.         local char = v.Character;
  31.         local head = char and char:FindFirstChild('Head');
  32.         if head and head.face.Texture:match('%d+') == targetFaceImage then
  33.             return char;
  34.         end;
  35.     end;
  36. end;
  37.  
  38. local function TeleportBehindTarget()
  39.     local targetCharacter = GetTargetCharacter();
  40.     if not targetCharacter then return; end;
  41.     rootPart.CFrame = targetCharacter.HumanoidRootPart.CFrame * CFrame.new(0, 0, 2);
  42. end;
  43.  
  44. local function ShootTarget()
  45.     local targetCharacter = GetTargetCharacter();
  46.     if not targetCharacter then return; end;
  47.     local head = targetCharacter.Head;
  48.     shootEvent:FireServer(RAY, head, head.Position, char:FindFirstChildOfClass('Tool'), 50);
  49. end;
  50.  
  51. CharacterAdded(localPlayer.Character);
  52. localPlayer.CharacterAdded:Connect(CharacterAdded);
  53.  
  54. game:GetService('UserInputService').InputBegan:Connect(function(input, gameProcessedEvent)
  55.     if gameProcessedEvent then return; end;
  56.     if input.KeyCode == X_KEYCODE then
  57.         TeleportBehindTarget();
  58.     elseif input.KeyCode == V_KEYCODE then
  59.         ShootTarget();
  60.     end;
  61. end);
RAW Paste Data