Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local RunService = game:GetService("RunService")
- local UserInputService = game:GetService("UserInputService")
- local Camera = workspace.CurrentCamera
- local LocalPlayer = Players.LocalPlayer
- local tracers = {}
- local boxes = {}
- local espEnabled = true -- Toggle flag
- -- Create GUI
- local screenGui = Instance.new("ScreenGui")
- screenGui.Name = "ESPInfoGui"
- screenGui.Parent = LocalPlayer:WaitForChild("PlayerGui")
- screenGui.ResetOnSpawn = false
- -- Create the main light blue frame
- local mainFrame = Instance.new("Frame")
- mainFrame.Size = UDim2.new(0, 300, 0, 150)
- mainFrame.Position = UDim2.new(0.5, -150, 0.5, -75)
- mainFrame.BackgroundColor3 = Color3.fromRGB(173, 216, 230) -- Light blue color
- mainFrame.BorderSizePixel = 0
- mainFrame.Parent = screenGui
- -- Create a label for the "Left Alt to enable/disable ESP"
- local espLabel = Instance.new("TextLabel")
- espLabel.Size = UDim2.new(1, 0, 0.5, 0)
- espLabel.Position = UDim2.new(0, 0, 0, 0)
- espLabel.BackgroundTransparency = 1
- espLabel.Text = "Left Alt to enable/disable ESP"
- espLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
- espLabel.TextScaled = true
- espLabel.Font = Enum.Font.GothamBold
- espLabel.TextStrokeTransparency = 0.5
- espLabel.Parent = mainFrame
- -- Create a label for the "Made by Mizzy"
- local madeByLabel = Instance.new("TextLabel")
- madeByLabel.Size = UDim2.new(1, 0, 0.5, 0)
- madeByLabel.Position = UDim2.new(0, 0, 0.5, 0)
- madeByLabel.BackgroundTransparency = 1
- madeByLabel.Text = "Made by Mizzy"
- madeByLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
- madeByLabel.TextScaled = true
- madeByLabel.Font = Enum.Font.GothamBold
- madeByLabel.TextStrokeTransparency = 0.5
- madeByLabel.Parent = mainFrame
- -- Create the close button (red "X")
- local closeButton = Instance.new("TextButton")
- closeButton.Size = UDim2.new(0, 40, 0, 40) -- Smaller size: 40x40
- closeButton.Position = UDim2.new(1, -40, 0, 0) -- Position adjusted to fit the smaller size
- closeButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
- closeButton.Text = "X"
- closeButton.TextColor3 = Color3.fromRGB(255, 255, 255)
- closeButton.Font = Enum.Font.GothamBold
- closeButton.TextScaled = true
- closeButton.Parent = mainFrame
- -- Function to close the GUI when the "X" button is clicked
- closeButton.MouseButton1Click:Connect(function()
- screenGui:Destroy() -- Close the GUI
- end)
- -- Function to apply ESP
- local function applyESP(player)
- if player ~= LocalPlayer then
- local function setup()
- local character = player.Character
- if not character or not character:FindFirstChild("HumanoidRootPart") then return end
- if character:FindFirstChild("ESPNameTag") then return end
- -- Team check: Change ESP color based on team
- local team = player.Team
- local espColor = Color3.fromRGB(0, 170, 255) -- Default color (non-team)
- if team then
- if team.Name == "TeamA" then
- espColor = Color3.fromRGB(0, 255, 0) -- Green for TeamA
- elseif team.Name == "TeamB" then
- espColor = Color3.fromRGB(255, 0, 0) -- Red for TeamB
- end
- end
- -- Billboard name tag
- local billboard = Instance.new("BillboardGui")
- billboard.Parent = character
- billboard.Name = "ESPNameTag"
- billboard.Adornee = character:FindFirstChild("Head") or character:FindFirstChild("HumanoidRootPart")
- billboard.Size = UDim2.new(0, 200, 0, 70) -- slightly taller to fit health bar
- billboard.StudsOffset = Vector3.new(0, 3.5, 0)
- billboard.AlwaysOnTop = true
- billboard.MaxDistance = math.huge
- -- Name label
- local nameLabel = Instance.new("TextLabel")
- nameLabel.Parent = billboard
- nameLabel.Size = UDim2.new(1, 0, 0.5, 0)
- nameLabel.Position = UDim2.new(0, 0, 0, 0)
- nameLabel.BackgroundTransparency = 1
- nameLabel.TextColor3 = espColor
- nameLabel.TextStrokeTransparency = 0
- nameLabel.Text = player.Name
- nameLabel.Font = Enum.Font.Legacy -- Font set to Legacy
- nameLabel.TextScaled = true
- -- Health bar background
- local healthBack = Instance.new("Frame")
- healthBack.Parent = billboard
- healthBack.Size = UDim2.new(1, -10, 0.15, 0)
- healthBack.Position = UDim2.new(0, 5, 0.55, 0)
- healthBack.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
- healthBack.BorderSizePixel = 0
- healthBack.Name = "HealthBackground"
- -- Health bar foreground (the actual green bar)
- local healthBar = Instance.new("Frame")
- healthBar.Parent = healthBack
- healthBar.Size = UDim2.new(1, 0, 1, 0)
- healthBar.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
- healthBar.BorderSizePixel = 0
- healthBar.Name = "HealthBar"
- -- Tracer
- local tracer = Drawing.new("Line")
- tracer.Thickness = 1.5
- tracer.Color = espColor
- tracer.Transparency = 1
- tracer.Visible = true
- tracers[player] = tracer
- -- Box ESP
- local box = Drawing.new("Square")
- box.Thickness = 1.5
- box.Color = espColor
- box.Transparency = 1
- box.Visible = true
- boxes[player] = box
- end
- -- If character already exists
- if player.Character then
- setup()
- end
- -- Or wait for character to load
- player.CharacterAdded:Connect(function()
- task.wait(0.5)
- setup()
- end)
- end
- end
- -- Cleanup when players leave
- Players.PlayerRemoving:Connect(function(player)
- if tracers[player] then tracers[player]:Remove() tracers[player] = nil end
- if boxes[player] then boxes[player]:Remove() boxes[player] = nil end
- end)
- -- Apply ESP to all current players
- for _, player in ipairs(Players:GetPlayers()) do
- applyESP(player)
- end
- -- New players
- Players.PlayerAdded:Connect(function(player)
- applyESP(player)
- end)
- -- Toggle ESP with LeftAlt
- UserInputService.InputBegan:Connect(function(input, gameProcessed)
- if not gameProcessed and input.KeyCode == Enum.KeyCode.LeftAlt then
- espEnabled = not espEnabled
- for _, tracer in pairs(tracers) do tracer.Visible = espEnabled end
- for _, box in pairs(boxes) do box.Visible = espEnabled end
- for _, player in ipairs(Players:GetPlayers()) do
- if player ~= LocalPlayer and player.Character then
- local tag = player.Character:FindFirstChild("ESPNameTag")
- if tag and tag:IsA("BillboardGui") then
- tag.Enabled = espEnabled
- end
- end
- end
- end
- end)
- -- Update each frame
- RunService.RenderStepped:Connect(function()
- if not espEnabled then return end
- for _, player in ipairs(Players:GetPlayers()) do
- if player ~= LocalPlayer then
- local character = player.Character
- local hrp = character and character:FindFirstChild("HumanoidRootPart")
- local head = character and character:FindFirstChild("Head")
- local humanoid = character and character:FindFirstChildOfClass("Humanoid")
- local tracer = tracers[player]
- local box = boxes[player]
- if character and hrp and head and humanoid and humanoid.Health > 0 then
- local top = Camera:WorldToViewportPoint(head.Position + Vector3.new(0, 0.3, 0))
- local bottom = Camera:WorldToViewportPoint(hrp.Position - Vector3.new(0, 2.5, 0))
- local height = math.abs(top.Y - bottom.Y)
- local width = height / 2
- local boxPos = Vector2.new(top.X - width / 2, top.Y)
- -- Update box
- if box then
- box.Position = boxPos
- box.Size = Vector2.new(width, height)
- box.Visible = true
- end
- -- Update tracer
- if tracer then
- local rootScreenPos, onScreen = Camera:WorldToViewportPoint(hrp.Position)
- if onScreen then
- tracer.From = Vector2.new(Camera.ViewportSize.X / 2, Camera.ViewportSize.Y)
- tracer.To = Vector2.new(rootScreenPos.X, rootScreenPos.Y)
- tracer.Visible = true
- else
- tracer.Visible = false
- end
- end
- -- Update health bar
- local tag = character:FindFirstChild("ESPNameTag")
- if tag and tag:FindFirstChild("HealthBackground") then
- local healthBar = tag.HealthBackground:FindFirstChild("HealthBar")
- if healthBar and humanoid then
- local healthRatio = humanoid.Health / humanoid.MaxHealth
- healthBar.Size = UDim2.new(math.clamp(healthRatio, 0, 1), 0, 1, 0)
- if healthRatio > 0.5 then
- healthBar.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
- elseif healthRatio > 0.2 then
- healthBar.BackgroundColor3 = Color3.fromRGB(255, 165, 0)
- else
- healthBar.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
- end
- end
- end
- else
- if box then box.Visible = false end
- if tracer then tracer.Visible = false end
- end
- end
- end
- end)
- -- Delay showing the GUI by 1 second
- wait(1)
- screenGui.Enabled = true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement