Camlock For Mobile
Key RequiredUniversal

Camlock For Mobile

Universal Scriptpubbpubb 188 views 5.1K executesUpdated Jul 13, 2026
Unrated
00
Lua Script•112 lines (2036 chars)
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local Player = Players.LocalPlayer
local Camera = workspace.CurrentCamera

local Locked = false
local Target = nil


-- Create GUI
local ScreenGui = Instance.new("ScreenGui")
ScreenGui.Parent = Player:WaitForChild("PlayerGui")
ScreenGui.ResetOnSpawn = false


-- Create Button
local Button = Instance.new("TextButton")
Button.Parent = ScreenGui
Button.Size = UDim2.new(0,60,0,60)
Button.Position = UDim2.new(0.8,0,0.7,0)

Button.Text = "👁️"
Button.TextScaled = true

-- Black button
Button.BackgroundColor3 = Color3.fromRGB(0,0,0)
Button.TextColor3 = Color3.fromRGB(255,255,255)

-- Draggable
Button.Active = true
Button.Draggable = true


-- Find target in front
local function FindTarget()

	local Character = Player.Character
	if not Character then return end

	local Root = Character:FindFirstChild("HumanoidRootPart")
	if not Root then return end

	local Closest = nil
	local Distance = math.huge

	for _, Plr in pairs(Players:GetPlayers()) do

		if Plr ~= Player and Plr.Character then

			local TargetRoot = Plr.Character:FindFirstChild("HumanoidRootPart")

			if TargetRoot then

				local Direction = (TargetRoot.Position - Root.Position).Unit
				local Facing = Root.CFrame.LookVector:Dot(Direction)

				if Facing > 0.5 then

					local Dist = (TargetRoot.Position - Root.Position).Magnitude

					if Dist < Distance then
						Distance = Dist
						Closest = Plr.Character
					end

				end
			end
		end
	end

	return Closest
end


-- Toggle lock
Button.MouseButton1Click:Connect(function()

	Locked = not Locked

	if Locked then
		Target = FindTarget()
	else
		Target = nil
	end

end)


-- Smooth camera lock
RunService.RenderStepped:Connect(function()

	if Locked and Target then

		local Root = Target:FindFirstChild("HumanoidRootPart")

		if Root then

			local NewCamera = CFrame.lookAt(
				Camera.CFrame.Position,
				Root.Position
			)

			Camera.CFrame = Camera.CFrame:Lerp(
				NewCamera,
				0.15
			)

		end
	end

end)

Features & Information

Camlock made by chatgpt😭

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts