Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local camera = workspace.CurrentCamera
- local ScreenX, ScreenY = workspace.CurrentCamera.ViewportSize.X, workspace.CurrentCamera.ViewportSize.Y
- local inversePi = 1 / math.pi
- _G.FOV = 9
- local magic = _G.FOV*inversePi
- _G.ignoreFOV = false
- local aim_through_list = {nil, nil, nil}
- local distance
- local ignore
- local distance2
- Pixels = ScreenX * ScreenY
- local mouse = game.Players.LocalPlayer:GetMouse()
- Radius = math.sqrt(Pixels*magic)
- local viable
- local your_head = game.Players.LocalPlayer.Character:FindFirstChild("Head")
- local ray_start
- local vector
- _G.ignoreWalls = false
- _G.weapon = "MP5K"
- _G.ShootingTeam = false
- local enabled = false
- local target
- local function ReturnF(player, bone)
- if not bone and player.Character:FindFirstChild(bone) then
- return {_, false}
- end
- return camera:WorldToScreenPoint(player.Character[bone].Position)
- end
- local function checksight(player)
- local screen_position, in_fov = ReturnF(player, "Head") -- end my life
- if not (in_fov or _G.ignoreFOV) then
- return false
- else -- bug here with fov checks
- if (not _G.ignoreFOV) and (_G.FOV~=-1) then
- local distance2 = (Vector2.new(screen_position.X, screen_position.Y) - Vector2.new(mouse.X, mouse.Y)).magnitude
- if distance2<=Radius then
- return player, screen_position
- end
- return false
- else
- return player, screen_position
- end
- end
- end
- local function ViableP()
- aim_through_list[1] = game.Players.LocalPlayer.Character
- local distance = 1000
- local closest_distance = 1000
- local most_viable_player = nil
- for i, player_being_checked in pairs(game:GetService("Players"):GetPlayers()) do
- local player_or_false, targets_coordinates = checksight(player_being_checked)
- if (player_or_false) then
- local char = player_being_checked.Character
- local target_torso = char and char:FindFirstChild "Torso"
- if (camera.Focus.p - camera.CoordinateFrame.p).magnitude <= 1 then
- ray_start = your_head.Position + your_head.CFrame.lookVector * 16 + Vector3.new(0, 4, 0)
- else
- ray_start = your_head.Position + Vector3.new(0, 4, 0)
- end
- if not targets_coordinates then
- distance = (Vector2.new(targets_coordinates.X, targets_coordinates.Y) - Vector2.new(mouse.X, mouse.Y)).magnitude
- else
- distance = (Vector2.new(targets_coordinates.X, targets_coordinates.Y) - Vector2.new(mouse.X, mouse.Y)).magnitude
- end
- vector = (target_torso.Position - ray_start)
- if (not targets_coordinates) or (distance <= closest_distance) then
- local new_ray = Ray.new(ray_start, vector.unit * 1000) -- "fire" ray and make sure to ignore our own character
- 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
- if (hit and hit:isDescendantOf(char)) or _G.ignoreWalls then
- closest_distance = distance
- most_viable_player = player_being_checked
- target = player_being_checked
- else
- most_viable_player = nil
- target = nil
- end -- hit or ignore walls
- end -- meets distance or no priority
- end
- end
- return most_viable_player
- end
- game:GetService('RunService').Heartbeat:connect(function(step)
- ViableP()
- workspace.DeadBody:ClearAllChildren()
- if workspace.Camera:FindFirstChild(_G.weapon) and target ~= nil then
- if target.TeamColor ~= game.Players.LocalPlayer.TeamColor then
- workspace.Camera[_G.weapon].Flame.Size = Vector3.new(1,5,1)
- workspace.Camera[_G.weapon].Flame.CFrame = target.Character.Head.CFrame*CFrame.new(0,0,1.9) -- this is where the magic is
- wait(0.7)
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement