Advertisement
SigmaBoy456

Wall check aimbot example #73

Sep 1st, 2024
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. local player = game.Players.LocalPlayer
  2. local character = player.Character
  3. local localroot = character:WaitForChild("HumanoidRootPart")
  4. local HeadCam = character:WaitForChild("Head")
  5.  
  6. local function closest()
  7. local range = math.huge
  8. local target = nil
  9. for _, v in pairs(game.Players:GetPlayers()) do
  10. if v ~= player and v.Character then
  11. local JN = v.Character:FindFirstChild("HumanoidRootPart")
  12. local JNR = v.Character:FindFirstChildOfClass("Humanoid")
  13. if JN and JNR and JNR.Health > 0 then
  14. local dist = (localroot.Position - JN.Position).magnitude
  15. if dist < range then
  16. range = dist
  17. target = v
  18. end
  19. end
  20. end
  21. end
  22. return target
  23. end
  24.  
  25. local function Non_Behind_Wall_Target()
  26. local t = closest()
  27. if t and t.Character then
  28. local vroot = t.Character:FindFirstChild("HumanoidRootPart")
  29. local vhumanoid = t.Character:FindFirstChildOfClass("Humanoid")
  30. if vroot and vhumanoid and vhumanoid.Health > 0 then
  31. local Direction = (vroot.Position - HeadCam.Position).unit * 1000
  32. local Ray_setting = RaycastParams.new()
  33. Ray_setting.FilterDescendantsInstances = {character}
  34. Ray_setting.FilterType = Enum.RaycastFilterType.Blacklist
  35. local result = workspace:Raycast(HeadCam.Position, Direction, Ray_setting)
  36. if result and result.Instance:IsDescendantOf(t.Character) then
  37. return vroot
  38. end
  39. end
  40. end
  41. return nil
  42. end
  43.  
  44. local Cam = workspace.CurrentCamera
  45. local function Update()
  46. local TARGET = Non_Behind_Wall_Target()
  47. if TARGET then
  48. Cam.CFrame = CFrame.new(Cam.CFrame.Position, TARGET.Position)
  49. end
  50. end
  51.  
  52. game:GetService("RunService").RenderStepped:Connect(Update)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement