Lock On UI
Key RequiredUniversal

Lock On UI

Universal ScriptNutShellScriptForReaNutShellScriptForRea 4.6K views 113 executesUpdated Feb 3, 2025
5.0/ 5(1 votes)
10100% Positive
Lua Script•161 lines (5245 chars)
local player = game.Players.LocalPlayer
local camera = game.Workspace.CurrentCamera
local runService = game:GetService("RunService")

local screenGui = Instance.new("ScreenGui")
screenGui.Parent = player:WaitForChild("PlayerGui")

local frame = Instance.new("Frame")
frame.Size = UDim2.new(0.25, 0, 0.2, 0)
frame.Position = UDim2.new(0.375, 0, 0.15, 0)
frame.BackgroundTransparency = 0.2
frame.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
frame.Active = true
frame.Draggable = true
frame.Parent = screenGui

local uiCorner = Instance.new("UICorner")
uiCorner.CornerRadius = UDim.new(0.1, 0)
uiCorner.Parent = frame

local uiGradient = Instance.new("UIGradient")
uiGradient.Color = ColorSequence.new{
    ColorSequenceKeypoint.new(0, Color3.fromRGB(30, 30, 30)),
    ColorSequenceKeypoint.new(1, Color3.fromRGB(100, 100, 100))
}
uiGradient.Parent = frame

local titleLabel = Instance.new("TextButton")
titleLabel.Size = UDim2.new(0.4, 0, 0.15, 0)
titleLabel.Position = UDim2.new(0.2, 0, 0, 0)
titleLabel.BackgroundTransparency = 1
titleLabel.Text = "Lock On UI"
titleLabel.TextColor3 = Color3.new(1, 1, 1)
titleLabel.TextScaled = true
titleLabel.Font = Enum.Font.Roboto
titleLabel.Parent = frame

local textBox = Instance.new("TextBox")
textBox.Size = UDim2.new(0.7, 0, 0.2, 0)
textBox.Position = UDim2.new(0.05, 0, 0.3, 0)
textBox.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
textBox.TextColor3 = Color3.new(1, 1, 1)
textBox.TextScaled = true
textBox.Font = Enum.Font.Roboto
textBox.PlaceholderText = "Enter Player Name"
textBox.Parent = frame

local bodyPartButton = Instance.new("TextButton")
bodyPartButton.Size = UDim2.new(0.2, 0, 0.2, 0)
bodyPartButton.Position = UDim2.new(0.75, 0, 0.3, 0)
bodyPartButton.BackgroundTransparency = 1
bodyPartButton.Text = "Head"
bodyPartButton.TextColor3 = Color3.new(1, 1, 1)
bodyPartButton.TextScaled = true
bodyPartButton.Font = Enum.Font.Roboto
bodyPartButton.Parent = frame

local SmoothnessButton = Instance.new("TextButton")
SmoothnessButton.Size = UDim2.new(0.2, 0, 0.2, 0)
SmoothnessButton.Position = UDim2.new(0.75, 0, 0.05, 0)
SmoothnessButton.BackgroundTransparency = 1
SmoothnessButton.Text = "Basic Smooth (0.25)"
SmoothnessButton.TextColor3 = Color3.new(1, 1, 1)
SmoothnessButton.TextScaled = true
SmoothnessButton.Font = Enum.Font.Roboto
SmoothnessButton.Parent = frame

local lockOnButton = Instance.new("TextButton")
lockOnButton.Size = UDim2.new(0.4, 0, 0.2, 0)
lockOnButton.Position = UDim2.new(0.05, 0, 0.65, 0)
lockOnButton.BackgroundColor3 = Color3.fromRGB(10, 10, 10)
lockOnButton.Text = "Lock On"
lockOnButton.TextColor3 = Color3.new(1, 1, 1)
lockOnButton.TextScaled = true
lockOnButton.Font = Enum.Font.Roboto
lockOnButton.Parent = frame

local lockOffButton = Instance.new("TextButton")
lockOffButton.Size = UDim2.new(0.4, 0, 0.2, 0)
lockOffButton.Position = UDim2.new(0.55, 0, 0.65, 0)
lockOffButton.BackgroundColor3 = Color3.fromRGB(10, 10, 10)
lockOffButton.Text = "Lock Off"
lockOffButton.TextColor3 = Color3.new(1, 1, 1)
lockOffButton.TextScaled = true
lockOffButton.Font = Enum.Font.Roboto
lockOffButton.Parent = frame

local targetPart = "Head"
local tracking = false
local targetCharacter
local Smoothness = 0.25
local ButtonType = 2
local db = false

titleLabel.MouseButton1Click:Connect(function()
    if db then return end
	db = true
    titleLabel.Text = "This is a Title."
	wait(0.4)
	db = false
	titleLabel.Text = "Lock On UI"
end)

SmoothnessButton.MouseButton1Click:Connect(function()
    if ButtonType == 2 then
	    ButtonType = 3
        Smoothness = 0.1
		SmoothnessButton.Text = "Normally Smooth (0.1)"
	elseif ButtonType == 3 then
	    ButtonType = 4
        Smoothness = 0.05
		SmoothnessButton.Text = "Very Smooth (0.05)"
    elseif ButtonType == 4 then
	    ButtonType = 1
        Smoothness = 1
		SmoothnessButton.Text = "Not Smooth (1)"
	elseif ButtonType == 1 then
	    ButtonType = 2
        Smoothness = 0.25
		SmoothnessButton.Text = "Basic Smooth (0.25)"
	end
end)

bodyPartButton.MouseButton1Click:Connect(function()
    if targetPart == "Head" then
        targetPart = "Torso"
        bodyPartButton.Text = "Torso"
	else
		targetPart = "Head"
		bodyPartButton.Text = "Head"
    end
end)

lockOnButton.MouseButton1Click:Connect(function()
    local inputName = textBox.Text:lower()
    for _, targetPlayer in pairs(game.Players:GetPlayers()) do
        if string.match(targetPlayer.Name:lower(), inputName) or string.match(targetPlayer.DisplayName:lower(), inputName) then
            if targetPlayer.Character then
                local part = targetPlayer.Character:FindFirstChild(targetPart)
                if part then
                    targetCharacter = part
                    tracking = true
                elseif not part and targetPart == "Torso" then
					targetCharacter = targetPlayer.Character:FindFirstChild("UpperTorso")
                    tracking = true
				end
            end
            break
        end
    end
end)

lockOffButton.MouseButton1Click:Connect(function()
    tracking = false
end)

runService.RenderStepped:Connect(function()
    if tracking and targetCharacter then
        camera.CFrame = camera.CFrame:Lerp(CFrame.new(camera.CFrame.Position, targetCharacter.Position), tonumber(Smoothness))
    end
end)

Features & Information

just copy the script got dang it btw theres no chat atfer you execute the script if you want to expose yourself then a new script coming up also more smooth equals more delayed
#universal#Gui#Lock on#Customziable

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts