local plr = game.Players.LocalPlayer
local connections = {}
local maingui = Instance.new("ScreenGui")
local btn = Instance.new("TextButton", maingui)
maingui.Size = UDim2.new(0, 200, 0, 200)
btn.Size = maingui.Size
btn.Text = "ESP: Off"
maingui.Position = UDim2.new(0.95, 0, 0.95, 0)
btn.Position = maingui.Position
maingui.Parent = plr.PlayerGui
function tag(plr)
local char = plr:FindFirstChild("Character")
local hrp = char:FindFirstChild("HumanoidRootPart")
if hrp then
local gui = Instance.new("BillboardGui", hrp)
gui.Name = "esp"
gui.Adornee = hrp
gui.LightInfluence = 0
gui.MaxDistance = math.huge
gui.Size = UDim2.new(2, 0, 2, 0)
local label = Instance.new("TextLabel", gui)
label.Text = plr.Name
label.Size = UDim2.new(1, 0, 1, 0)
connections[plr.Name] = char.Humanoid.Died:connect(function()
plr.CharacterAdded:connect(function() tag(plr) end)
end)
end
end
function untag(plr)
local char = plr:FindFirstChild("Character")
local hrp = char:FindFirstChild("HumanoidRootPart")
if hrp then
local gui = hrp:FindFirstChild("esp")
if gui then
gui:Destroy()
connections[plr.Name]:Disconnect()
end
end
end
btn.MouseButton1Click:connect(function()
if btn.Text == "ESP: Off" then
btn.Text = "ESP: On"
for i, p in pairs(game.Players:GetChildren()) do
local char = p:FindFirstChild("Character")
if char then
if char:FindFirstChild("HumanoidRootPart") the
tag(p)
end
end
end
elseif btn.Text == "ESP: On" then
btn.Text = "ESP: Off"
for i, p in pairs(game.Players:GetChildren()) do
local char = p:FindFirstChild("Character")
if char then
if char:FindFirstChild("HumanoidRootPart") the
untag(p)
end
end
end
end
end
The button won't show up, why?
Cancel
Post