Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.42 KB | None | 0 0
  1. local camera = workspace.CurrentCamera
  2. local ScreenX, ScreenY = workspace.CurrentCamera.ViewportSize.X, workspace.CurrentCamera.ViewportSize.Y
  3. local inversePi = 1 / math.pi
  4. _G.FOV = 9
  5. local magic = _G.FOV*inversePi
  6. _G.ignoreFOV = false
  7. local aim_through_list = {nil, nil, nil}
  8. local distance
  9. local ignore
  10. local distance2
  11. Pixels = ScreenX * ScreenY
  12. local mouse = game.Players.LocalPlayer:GetMouse()
  13. Radius = math.sqrt(Pixels*magic)
  14. local viable
  15. local your_head = game.Players.LocalPlayer.Character:FindFirstChild("Head")
  16. local ray_start
  17. local vector
  18. _G.ignoreWalls = false
  19. _G.weapon = "MP5K"
  20. _G.ShootingTeam = false
  21. local enabled = false
  22. local target
  23.  
  24. local function ReturnF(player, bone)
  25. if not bone and player.Character:FindFirstChild(bone) then
  26. return {_, false}
  27. end
  28. return camera:WorldToScreenPoint(player.Character[bone].Position)
  29. end
  30. local function checksight(player)
  31. local screen_position, in_fov = ReturnF(player, "Head") -- end my life
  32. if not (in_fov or _G.ignoreFOV) then
  33. return false
  34. else -- bug here with fov checks
  35. if (not _G.ignoreFOV) and (_G.FOV~=-1) then
  36. local distance2 = (Vector2.new(screen_position.X, screen_position.Y) - Vector2.new(mouse.X, mouse.Y)).magnitude
  37. if distance2<=Radius then
  38. return player, screen_position
  39. end
  40. return false
  41. else
  42. return player, screen_position
  43. end
  44. end
  45. end
  46. local function ViableP()
  47. aim_through_list[1] = game.Players.LocalPlayer.Character
  48. local distance = 1000
  49. local closest_distance = 1000
  50. local most_viable_player = nil
  51. for i, player_being_checked in pairs(game:GetService("Players"):GetPlayers()) do
  52. local player_or_false, targets_coordinates = checksight(player_being_checked)
  53. if (player_or_false) then
  54. local char = player_being_checked.Character
  55. local target_torso = char and char:FindFirstChild "Torso"
  56. if (camera.Focus.p - camera.CoordinateFrame.p).magnitude <= 1 then
  57. ray_start = your_head.Position + your_head.CFrame.lookVector * 16 + Vector3.new(0, 4, 0)
  58. else
  59. ray_start = your_head.Position + Vector3.new(0, 4, 0)
  60. end
  61. if not targets_coordinates then
  62. distance = (Vector2.new(targets_coordinates.X, targets_coordinates.Y) - Vector2.new(mouse.X, mouse.Y)).magnitude
  63. else
  64. distance = (Vector2.new(targets_coordinates.X, targets_coordinates.Y) - Vector2.new(mouse.X, mouse.Y)).magnitude
  65. end
  66. vector = (target_torso.Position - ray_start)
  67. if (not targets_coordinates) or (distance <= closest_distance) then
  68. local new_ray = Ray.new(ray_start, vector.unit * 1000) -- "fire" ray and make sure to ignore our own character
  69. local hit, position = workspace:FindPartOnRayWithIgnoreList(new_ray, aim_through_list) -- check if the ray hit anything and if it's a descendant of the target's character
  70. if (hit and hit:isDescendantOf(char)) or _G.ignoreWalls then
  71. closest_distance = distance
  72. most_viable_player = player_being_checked
  73. target = player_being_checked
  74. else
  75. most_viable_player = nil
  76. target = nil
  77. end -- hit or ignore walls
  78. end -- meets distance or no priority
  79. end
  80. end
  81. return most_viable_player
  82. end
  83.  
  84. game:GetService('RunService').Heartbeat:connect(function(step)
  85. ViableP()
  86. workspace.DeadBody:ClearAllChildren()
  87. if workspace.Camera:FindFirstChild(_G.weapon) and target ~= nil then
  88. if target.TeamColor ~= game.Players.LocalPlayer.TeamColor then
  89. workspace.Camera[_G.weapon].Flame.Size = Vector3.new(1,5,1)
  90. workspace.Camera[_G.weapon].Flame.CFrame = target.Character.Head.CFrame*CFrame.new(0,0,1.9) -- this is where the magic is
  91. wait(0.7)
  92. end
  93. end
  94. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement