aimlock
Key RequiredUniversal

aimlock

Universal ScriptJoshJosh 14.5K views 70 executesUpdated Jun 22, 2024
0.6/ 5(9 votes)
1811% Positive
Lua Script•43 lines (1502 chars)
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local localPlayer = Players.LocalPlayer
local camera = game.Workspace.CurrentCamera

-- Function to lock the camera onto the selected player
local function lockCameraOnPlayer(targetPlayer)
    if not targetPlayer or not targetPlayer.Character then return end

    -- Disable default camera scripts
    localPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
    localPlayer.CameraMaxZoomDistance = 16

    -- Set the camera to follow the target player
    RunService:BindToRenderStep("CameraFollow", Enum.RenderPriority.Camera.Value, function()
        if targetPlayer.Character and targetPlayer.Character:FindFirstChild("Head") then
            camera.CFrame = CFrame.new(camera.CFrame.Position, targetPlayer.Character.Head.Position)
        end
    end)
end

-- Function to stop locking the camera
local function unlockCamera()
    -- Re-enable default camera scripts
    localPlayer.CameraMode = Enum.CameraMode.Classic
    localPlayer.CameraMaxZoomDistance = 128

    -- Unbind the camera follow function
    RunService:UnbindFromRenderStep("CameraFollow")
end

-- Example: Lock camera onto another player named "TargetPlayerName"
local targetPlayerName = "username"
local targetPlayer = Players:FindFirstChild(targetPlayerName)

if targetPlayer then
    lockCameraOnPlayer(targetPlayer)
else
    warn("Target player not found")
end

-- To unlock the camera, call unlockCamera()
-- Example: unlockCamera()

Features & Information

aimlock but you got put there user

Community Comments (2)

LazerdimLazerdimJun 22, 2024(edited)

@josh what if you are 1v2+ and u have to take the time to type both of there user so u dont die

Argetnar_Doku4kaArgetnar_Doku4kaJun 23, 2024(edited)

@Josh Thank you for your work, you have helped me well and sped up my work :)

More Scripts for Universal Scripts