Advertisement
ProScripter29

FE Player ESP

Dec 7th, 2022 (edited)
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.42 KB | Gaming | 0 0
  1. -- Created by HappyH0lidays2021
  2.  
  3. -- This script will work for any ROBLOX game
  4.  
  5. local Player = game.Players.LocalPlayer
  6. local Players = game:GetService("Players")
  7.  
  8. local Camera = workspace.CurrentCamera
  9.  
  10. local MaxDistance = 5000
  11.  
  12. -- Creating the Button --
  13.  
  14. local ButtonGui = Instance.new("ScreenGui", Player.PlayerGui)
  15. ButtonGui.Name = "_buttonGui"
  16. ButtonGui.ResetOnSpawn = false
  17. ButtonGui.Enabled = true
  18. ButtonGui.ZIndexBehavior = Enum.ZIndexBehavior.Global
  19.  
  20. local Button = Instance.new("TextButton", ButtonGui)
  21. Button.Name = "_button-toggle"
  22. Button.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
  23. Button.BorderColor3 = Color3.fromRGB(0, 225, 0)
  24. Button.BorderSizePixel = 3
  25. Button.Position = UDim2.new(0.408, 0, 0.728, 0)
  26. Button.Size = UDim2.new(0.182, 0, 0.058, 0)
  27. Button.Text = "Toggle ESP"
  28. Button.Font = Enum.Font.GothamBlack
  29. Button.TextColor3 = Color3.new(1, 1, 1)
  30. Button.TextSize = 15
  31. Button.ZIndex = 100000
  32.  
  33. local IsTracking = true -- Automatically set tracking to true when script is executed
  34.  
  35. --------------------------------------------------------------------------------------------------------------
  36.  
  37. -- Functions
  38.  
  39. --------------------------------------------------------------------------------------------------------------
  40.  
  41. local function EspTrack(Humanoid, IsAnNPC)
  42.     local Root
  43.     if Humanoid.RigType == Enum.HumanoidRigType.R15 then -- Check if the RigType of the player is R15 or R6
  44.         if Humanoid.Parent:FindFirstChild("UpperTorso"):IsA("CharacterMesh") then
  45.             Humanoid.Parent:FindFirstChild("UpperTorso").Name = "_UpperTorso" -- Rename the Meshes that are called "UpperTorso" to avoid the script from mistaking it as a BodyPart
  46.         end
  47.         Root = Humanoid.Parent:FindFirstChild("UpperTorso")
  48.     else
  49.         if Humanoid.Parent:FindFirstChild("Torso"):IsA("CharacterMesh") then
  50.             Humanoid.Parent:FindFirstChild("Torso").Name = "_Torso" -- Rename the Meshes that are called "Torso" to avoid the script from mistaking it as a BodyPart
  51.         end
  52.         Root = Humanoid.Parent:FindFirstChild("Torso")
  53.     end
  54.     if Root then
  55.         task.spawn(function()
  56.             local TorsoEsp = Instance.new("BoxHandleAdornment", Root)
  57.             if IsAnNPC then
  58.                 TorsoEsp.Color3 = Color3.fromRGB(0, 170, 255)
  59.             elseif not IsAnNPC then
  60.                 TorsoEsp.Color3 = Color3.fromRGB(0,255,0)
  61.             end
  62.             TorsoEsp.Transparency = 0.5
  63.             TorsoEsp.Adornee = Root.Parent.HumanoidRootPart
  64.             TorsoEsp.AdornCullingMode = Enum.AdornCullingMode.Never
  65.             TorsoEsp.AlwaysOnTop = true
  66.             TorsoEsp.Size = Vector3.new(4.4,5.4,1.4)
  67.             TorsoEsp.CFrame = TorsoEsp.CFrame - Vector3.new(0,0.5,0)
  68.             TorsoEsp.Visible = true
  69.             TorsoEsp.ZIndex = 5
  70.             -- Creating the Name ESP
  71.             local NameEsp = Instance.new("BillboardGui", Humanoid.Parent:FindFirstChild("Head"))
  72.             NameEsp.Name = "_name-esp-gui"
  73.             NameEsp.AlwaysOnTop = true
  74.             NameEsp.Enabled = true
  75.             NameEsp.LightInfluence = 0
  76.             NameEsp.Size = UDim2.new(0, 200, 0, 15)
  77.             NameEsp.StudsOffset = Vector3.new(0, 2.1, 0)
  78.             local NameEspText = Instance.new("TextLabel", NameEsp)
  79.             NameEspText.Name = "_name-esp-text"
  80.             NameEspText.BackgroundTransparency = 1
  81.             NameEspText.Size = UDim2.new(0, 200, 0, 15)
  82.             NameEspText.Font = Enum.Font.SourceSansBold
  83.             if IsAnNPC then
  84.                 NameEspText.Text = "[NPC] "..Humanoid.Parent.Name
  85.                 NameEspText.TextColor3 = Color3.fromRGB(0, 170, 255)
  86.             elseif not IsAnNPC then
  87.                 NameEspText.Text = Humanoid.Parent.Name
  88.                 NameEspText.TextColor3 = Color3.fromRGB(0, 255, 0)
  89.             end
  90.             NameEspText.TextScaled = true
  91.             NameEspText.TextStrokeTransparency = 0
  92.             -- Creating the Distance ESP
  93.             local DistanceEsp = Instance.new("BillboardGui", Root)
  94.             DistanceEsp.Name = "_distance-esp-gui"
  95.             DistanceEsp.AlwaysOnTop = true
  96.             DistanceEsp.Enabled = true
  97.             DistanceEsp.LightInfluence = 0
  98.             DistanceEsp.Size = UDim2.new(0, 200, 0, 15)
  99.             DistanceEsp.StudsOffset = Vector3.new(0, -4.3, 0)
  100.             local NameEspDistance = Instance.new("TextLabel", DistanceEsp)
  101.             NameEspDistance.Name = "_distance-esp-text"
  102.             NameEspDistance.BackgroundTransparency = 1
  103.             NameEspDistance.Size = UDim2.new(0, 200, 0, 15)
  104.             NameEspDistance.Font = Enum.Font.SourceSansBold
  105.             NameEspDistance.TextScaled = true
  106.             NameEspDistance.TextStrokeTransparency = 0
  107.             ------------------------------------------------------------------------
  108.             while Root and IsTracking == true do -- While Root still exists and Tracking is on, run the function
  109.                 local RayCast = Ray.new(Root.Position, (Player.Character.HumanoidRootPart.Position - Root.Position).unit*100)
  110.                 local Part, Position, Normal = game.Workspace:FindPartOnRay(RayCast, Player.Character, false,true)
  111.                 local Dist = (Player.Character.HumanoidRootPart.Position - Root.Position).magnitude
  112.                 if (Dist > MaxDistance) then
  113.                     warn("Maximum Distance Reached")
  114.                     break
  115.                 end
  116.                 Part = Instance.new("Part")
  117.                 Part.Name = "_esp-track-part"
  118.                 Part.Parent = Humanoid.Parent
  119.                 Part.Anchored = true
  120.                 Part.CanCollide = false
  121.                 Part.Size = Vector3.new(0.15, 0.15, Dist)
  122.                 Part.Transparency = 1
  123.                 Part.CFrame = CFrame.new(Root.Position ,Position) * CFrame.new(0, 0, -Dist/2)
  124.                 local Highlight = Instance.new("BoxHandleAdornment", Part)     
  125.                 if IsAnNPC then
  126.                     Highlight.Color3 = Color3.fromRGB(0, 170, 255)
  127.                     NameEspDistance.Text = math.round(Dist).." Studs"
  128.                     NameEspDistance.TextColor3 = Color3.fromRGB(0, 170, 255)
  129.                 elseif not IsAnNPC then
  130.                     Highlight.Color3 = Color3.fromRGB(0,255,0)
  131.                     NameEspDistance.Text = math.round(Dist).." Studs"
  132.                     NameEspDistance.TextColor3 = Color3.fromRGB(0, 255, 0)
  133.                 end
  134.                 Highlight.Transparency = 0.5
  135.                 Highlight.Adornee = Part
  136.                 Highlight.AdornCullingMode = Enum.AdornCullingMode.Never
  137.                 Highlight.AlwaysOnTop = true
  138.                 Highlight.Size = Vector3.new(0.17, 0.17, Dist)
  139.                 Highlight.Visible = true
  140.                 Highlight.ZIndex = 0
  141.                 task.wait()
  142.                 Part:Destroy()
  143.             end
  144.             -- Root no longer exists or Tracking was set to off
  145.             print('Tracking ended for "'..Root.Parent.Name..'"')
  146.             if Root then
  147.                 NameEsp:Destroy()
  148.                 DistanceEsp:Destroy()
  149.                 TorsoEsp:Destroy()
  150.             else
  151.                 warn('Root no longer exists in the Character "'..Root.Parent.Name..'"')
  152.             end
  153.         end)
  154.     end
  155. end
  156.  
  157. local function EspTrackTool(Tool) -- Exactly the same function as tracking a player, but its a Tool instead
  158.     local Root = Tool.Handle
  159.     if Root then
  160.         task.spawn(function()
  161.             local NameEsp = Instance.new("BillboardGui", Root)
  162.             NameEsp.Name = "_name-esp-gui"
  163.             NameEsp.AlwaysOnTop = true
  164.             NameEsp.Enabled = true
  165.             NameEsp.LightInfluence = 0
  166.             NameEsp.Size = UDim2.new(0, 200, 0, 15)
  167.             NameEsp.StudsOffset = Vector3.new(0, 2.1, 0)
  168.             local NameEspText = Instance.new("TextLabel", NameEsp)
  169.             NameEspText.Name = "_name-esp-text"
  170.             NameEspText.BackgroundTransparency = 1
  171.             NameEspText.Size = UDim2.new(0, 200, 0, 15)
  172.             NameEspText.Font = Enum.Font.SourceSansBold
  173.             NameEspText.Text = "[TOOL] "..Root.Parent.Name
  174.             NameEspText.TextColor3 = Color3.fromRGB(255, 0, 0)
  175.             NameEspText.TextScaled = true
  176.             NameEspText.TextStrokeTransparency = 0
  177.             --
  178.             while Root and IsTracking == true do
  179.                 local RayCast = Ray.new(Root.Position, (Player.Character.HumanoidRootPart.Position - Root.Position).unit*100)
  180.                 local Part, Position, Normal = game.Workspace:FindPartOnRay(RayCast, Player.Character, false,  true)
  181.                 local Dist = (Player.Character.HumanoidRootPart.Position - Root.Position).magnitude
  182.                 if (Dist > MaxDistance) then
  183.                     warn("Maximum Distance Reached")
  184.                     break
  185.                 end
  186.                 -- Raycast Part --
  187.                 Part = Instance.new("Part")
  188.                 Part.Name = "_esp-track-part"
  189.                 Part.Parent = Root
  190.                 Part.Anchored = true
  191.                 Part.CanCollide = false
  192.                 Part.Size = Vector3.new(0.1, 0.1, Dist)
  193.                 Part.Transparency = 1
  194.                 Part.CFrame = CFrame.new(Root.Position, Position) * CFrame.new(0, 0, -Dist/2)
  195.                 local ToolEsp = Instance.new("BoxHandleAdornment", Part)       
  196.                 ToolEsp.Transparency = 0.5
  197.                 ToolEsp.Adornee = Part
  198.                 ToolEsp.AdornCullingMode = Enum.AdornCullingMode.Never
  199.                 ToolEsp.AlwaysOnTop = true
  200.                 ToolEsp.Size = Vector3.new(0.17, 0.17, Dist)
  201.                 ToolEsp.Color3 = Color3.fromRGB(255, 0, 0)
  202.                 ToolEsp.Visible = true
  203.                 ToolEsp.ZIndex = 0
  204.                 task.wait()
  205.                 Part:Destroy()
  206.             end
  207.             -- Tool no longer exists or Tracking was set to off
  208.             print('Tracking ended for "'..Root.Parent.Name..'"')
  209.             if Root then
  210.                 NameEsp:Destroy()
  211.             else
  212.                 warn("Tool no longer exists")
  213.             end
  214.         end)
  215.     end
  216. end
  217.  
  218. local function CheckDistance(Object, IsAnNPC)
  219.     if Object then
  220.         local Torso
  221.         if Object.RigType == Enum.HumanoidRigType.R15 then
  222.             Torso = Object.Parent:FindFirstChild("UpperTorso")
  223.         else
  224.             Torso = Object.Parent:FindFirstChild("Torso")
  225.         end
  226.         local Distance = (Player.Character.HumanoidRootPart.Position - Torso.Position).magnitude
  227.         if Distance <= MaxDistance then -- Maximum distance of the tracker is 5000 studs by default
  228.             EspTrack(Object, IsAnNPC)
  229.         else
  230.             -- Ignore the Character as it is too far from the LocalPlayer
  231.             print(Object.Parent.Name.." is too far from the Player")
  232.         end
  233.     end
  234. end
  235.  
  236. local MainFunction = function()
  237.     task.spawn(function()
  238.         while task.wait(0.1) do
  239.             if IsTracking then -- If tracking is on, run the function
  240.                 for _, Thing in pairs(workspace:GetDescendants()) do -- Get all objects found in the workspace
  241.                     if Thing:IsA("Humanoid") and (Thing.Health > 0) and (Thing.Parent ~= Player.Character) then -- Check if object IS a Humanoid and Character is different from the LocalPlayer's Character
  242.                         if Players:GetPlayerFromCharacter(Thing.Parent) and not Thing.Parent:FindFirstChild("_esp-track-part") then
  243.                             CheckDistance(Thing, false) -- Check the distance of the Player
  244.                         elseif not Thing.Parent:FindFirstChild("_esp-track-part") then
  245.                             CheckDistance(Thing, true) -- Check the distance of the NPC
  246.                         end
  247.                     elseif Thing:IsA("Tool") then
  248.                         if Thing:FindFirstChild("Handle") then
  249.                             if not Thing.Handle:FindFirstChild("_esp-track-part") then
  250.                                 EspTrackTool(Thing) -- Track the Tool
  251.                             end
  252.                         end
  253.                     end
  254.                 end
  255.             end
  256.         end
  257.     end)
  258. end
  259.  
  260. Button.MouseButton1Click:Connect(function()
  261.     if IsTracking then
  262.         -- Disable Tracking
  263.         IsTracking = false
  264.         Button.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
  265.         Button.BorderColor3 = Color3.fromRGB(225, 0, 0)
  266.     else
  267.         -- Enable Tracking
  268.         IsTracking = true
  269.         Button.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
  270.         Button.BorderColor3 = Color3.fromRGB(0, 225, 0)
  271.     end
  272. end)
  273.  
  274. task.wait() -- Wait until everything is loaded
  275.  
  276. MainFunction() -- Run the main function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement