CCCPaste

Prison Life

--[[==================================================
     PLAYER VISUAL + AIM LOCK SCRIPT (ALL-IN-ONE)
     - Display name + health (side by side, lifted higher)
     - Team color outlines
     - Q key aim-lock
     - Includes Infinite Yield Admin
==================================================]]

-- Load Infinite Yield Admin
loadstring(game:HttpGet('https://raw.githubusercontent.com/EdgeIY/infiniteyield/master/source'))()

-----------------------------------------------------
-- Services
-----------------------------------------------------
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local RunService = game:GetService("RunService")
local Camera = workspace.CurrentCamera
local UIS = game:GetService("UserInputService")

-----------------------------------------------------
-- Variables
-----------------------------------------------------
local mouse = LocalPlayer:GetMouse()
local holding = false
local lockedTarget = nil

-----------------------------------------------------
-- 1. NAME TAG + HEALTH (SIDE BY SIDE, LIFTED)
-----------------------------------------------------
local function addNameTag(character, plr)
	local head = character:WaitForChild("Head", 5)
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	if not head or not humanoid then return end

	local billboard = Instance.new("BillboardGui")
	billboard.Parent = head
	billboard.Adornee = head
	billboard.Size = UDim2.new(0, 200, 0, 50)
	billboard.StudsOffset = Vector3.new(0, 3.2, 0) -- raised higher above the head
	billboard.AlwaysOnTop = true

	local frame = Instance.new("Frame")
	frame.Parent = billboard
	frame.BackgroundTransparency = 1
	frame.Size = UDim2.new(1, 0, 1, 0)

	-- Display name
	local nameLabel = Instance.new("TextLabel")
	nameLabel.Parent = frame
	nameLabel.BackgroundTransparency = 1
	nameLabel.AnchorPoint = Vector2.new(0.5, 0.5)
	nameLabel.Position = UDim2.new(0.5, -20, 0.5, 0)
	nameLabel.Text = plr.DisplayName
	nameLabel.TextColor3 = Color3.new(1, 1, 1)
	nameLabel.TextStrokeTransparency = 0.5
	nameLabel.Font = Enum.Font.GothamBold
	nameLabel.TextScaled = false
	nameLabel.TextSize = 18

	-- Health (right next to name)
	local healthLabel = Instance.new("TextLabel")
	healthLabel.Parent = frame
	healthLabel.BackgroundTransparency = 1
	healthLabel.AnchorPoint = Vector2.new(0, 0.5)
	healthLabel.Position = UDim2.new(0.5, nameLabel.TextBounds.X / 2 + 10, 0.5, 0)
	healthLabel.Text = tostring(math.floor(humanoid.Health))
	healthLabel.TextColor3 = Color3.new(1, 1, 1)
	healthLabel.TextStrokeTransparency = 0.5
	healthLabel.Font = Enum.Font.GothamBold
	healthLabel.TextScaled = false
	healthLabel.TextSize = 16

	-- Update scaling + position + health
	RunService.RenderStepped:Connect(function()
		if head and head:IsDescendantOf(workspace) and humanoid then
			local distance = (Camera.CFrame.Position - head.Position).Magnitude
			local size = math.clamp(30 - distance / 4, 10, 30)
			nameLabel.TextSize = size
			healthLabel.TextSize = math.clamp(size * 0.8, 8, 22)
			healthLabel.Text = tostring(math.floor(humanoid.Health))
			healthLabel.Position = UDim2.new(0.5, nameLabel.TextBounds.X / 2 + 8, 0.5, 0)
		end
	end)
end

-----------------------------------------------------
-- 2. TEAM OUTLINE (CHARM)
-----------------------------------------------------
local function addOutline(character, teamColor)
	for _, part in pairs(character:GetChildren()) do
		if part:IsA("BasePart") then
			local highlight = Instance.new("Highlight")
			highlight.Parent = part
			highlight.Adornee = part
			highlight.FillTransparency = 1
			highlight.OutlineColor = teamColor.Color
			highlight.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
		end
	end
end

-----------------------------------------------------
-- 3. AIM LOCK (Q TO LOCK)
-----------------------------------------------------
local function getClosestTorso()
	local closest, shortest = nil, math.huge
	for _, plr in pairs(Players:GetPlayers()) do
		if plr ~= LocalPlayer and plr.Character and plr.Character:FindFirstChild("HumanoidRootPart") then
			local torso = plr.Character.HumanoidRootPart
			local pos, onScreen = Camera:WorldToViewportPoint(torso.Position)
			if onScreen then
				local dist = (Vector2.new(pos.X, pos.Y) - Vector2.new(mouse.X, mouse.Y)).Magnitude
				if dist < shortest then
					shortest = dist
					closest = torso
				end
			end
		end
	end
	return closest
end

RunService.RenderStepped:Connect(function()
	if holding and lockedTarget then
		if lockedTarget.Parent and lockedTarget:IsDescendantOf(workspace) then
			Camera.CFrame = CFrame.new(Camera.CFrame.Position, lockedTarget.Position)
		else
			lockedTarget = nil
		end
	end
end)

UIS.InputBegan:Connect(function(input, gp)
	if not gp and input.KeyCode == Enum.KeyCode.Q then
		if not holding then
			lockedTarget = getClosestTorso()
			holding = true
		end
	end
end)

UIS.InputEnded:Connect(function(input, gp)
	if not gp and input.KeyCode == Enum.KeyCode.Q then
		holding = false
		lockedTarget = nil
	end
end)

-----------------------------------------------------
-- 4. APPLY TAGS + OUTLINES TO ALL PLAYERS
-----------------------------------------------------
local function onCharacterAdded(character, plr)
	task.wait(0.5)
	addNameTag(character, plr)
	local teamColor = plr.TeamColor or BrickColor.new("White")
	addOutline(character, teamColor)
end

for _, plr in pairs(Players:GetPlayers()) do
	if plr ~= LocalPlayer then
		plr.CharacterAdded:Connect(function(char)
			onCharacterAdded(char, plr)
		end)
		if plr.Character then
			onCharacterAdded(plr.Character, plr)
		end
	end
end

Players.PlayerAdded:Connect(function(plr)
	if plr ~= LocalPlayer then
		plr.CharacterAdded:Connect(function(char)
			onCharacterAdded(char, plr)
		end)
	end
end)