Advertisement
NotExotic

New Esp

Sep 15th, 2023
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. print("Esp")
  2.  
  3. local Players = game:GetService("Players")
  4. local UserInputService = game:GetService("UserInputService")
  5. local Camera = game.Workspace.CurrentCamera
  6.  
  7. -- Function to create a hitbox for a character
  8. local function createHitbox(character)
  9. for _, part in pairs(character:GetChildren()) do
  10. if part:IsA("BasePart") then
  11. local hitbox = part:FindFirstChild("Hitbox")
  12. if not hitbox then
  13. hitbox = Instance.new("SelectionBox")
  14. hitbox.Name = "Hitbox"
  15. hitbox.Adornee = part
  16. hitbox.Parent = part
  17. hitbox.Color3 = Color3.new(1, 0, 0) -- Set the hitbox color (red in this example)
  18. hitbox.LineThickness = 0.05 -- Adjust the hitbox thickness as needed
  19. end
  20. end
  21. end
  22. end
  23.  
  24. -- Function to remove hitboxes from a character
  25. local function removeHitbox(character)
  26. for _, part in pairs(character:GetChildren()) do
  27. if part:IsA("BasePart") then
  28. local hitbox = part:FindFirstChild("Hitbox")
  29. if hitbox then
  30. hitbox:Destroy()
  31. end
  32. end
  33. end
  34. end
  35.  
  36. -- Function to draw hitboxes for a player
  37. local function drawPlayerHitbox(player)
  38. local character = player.Character
  39. if character and player ~= Players.LocalPlayer then
  40. createHitbox(character)
  41. end
  42. end
  43.  
  44. -- Function to handle player character changes
  45. local function onCharacterAdded(character)
  46. drawPlayerHitbox(Players:GetPlayerFromCharacter(character))
  47. end
  48.  
  49. local function onCharacterRemoved(character)
  50. removeHitbox(character)
  51. end
  52.  
  53. -- Function to continuously check for new players and draw their hitboxes
  54. local function checkForNewPlayers()
  55. while true do
  56. for _, player in pairs(Players:GetPlayers()) do
  57. drawPlayerHitbox(player)
  58. end
  59. wait(1) -- Adjust the delay as needed (1 second in this example)
  60. end
  61. end
  62.  
  63. -- Start the loop in a separate thread to avoid script termination
  64. spawn(checkForNewPlayers)
  65.  
  66. -- Connect an event to draw hitboxes for newly added players
  67. Players.PlayerAdded:Connect(function(player)
  68. player.CharacterAdded:Connect(onCharacterAdded)
  69. player.CharacterRemoving:Connect(onCharacterRemoved)
  70. drawPlayerHitbox(player)
  71. end)
  72.  
  73. -- Check if the LocalPlayer is in first-person view and hide their hitboxes
  74. UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
  75. if input.UserInputType == Enum.UserInputType.MouseWheel then
  76. local player = Players.LocalPlayer
  77. local character = player.Character
  78. if character then
  79. if Camera:IsInFirstPerson() then
  80. removeHitbox(character)
  81. else
  82. drawPlayerHitbox(player)
  83. end
  84. end
  85. end
  86. end)
  87.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement