-- Aimlock Toggle UI para juegos de battlegrounds (solo jugadores reales)
-- Colocar como LocalScript en StarterPlayerScripts
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local localPlayer = Players.LocalPlayer
local camera = workspace.CurrentCamera
--========================
-- UI: Frame movible + Toggle
--========================
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "AimlockUI"
screenGui.ResetOnSpawn = false
screenGui.IgnoreGuiInset = true
screenGui.Parent = localPlayer:WaitForChild("PlayerGui")
local frame = Instance.new("Frame")
frame.Size = UDim2.new(0, 140, 0, 60)
frame.Position = UDim2.new(0, 30, 0, 200)
frame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
frame.Active = true
frame.Draggable = true
frame.Parent = screenGui
local uiCorner = Instance.new("UICorner")
uiCorner.CornerRadius = UDim.new(0, 10)
uiCorner.Parent = frame
local title = Instance.new("TextLabel")
title.Size = UDim2.new(1, -10, 0, 24)
title.Position = UDim2.new(0, 5, 0, 5)
title.BackgroundTransparency = 1
title.Text = "Aimlock"
title.TextColor3 = Color3.fromRGB(255, 255, 255)
title.TextScaled = true
title.Font = Enum.Font.GothamBold
title.Parent = frame
local toggleBtn = Instance.new("TextButton")
toggleBtn.Size = UDim2.new(1, -20, 0, 26)
toggleBtn.Position = UDim2.new(0, 10, 0, 30)
toggleBtn.BackgroundColor3 = Color3.fromRGB(180, 0, 0) -- OFF rojo
toggleBtn.Text = "OFF"
toggleBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
toggleBtn.TextScaled = true
toggleBtn.Font = Enum.Font.GothamBold
toggleBtn.Parent = frame
local btnCorner = Instance.new("UICorner")
btnCorner.CornerRadius = UDim.new(0, 8)
btnCorner.Parent = toggleBtn
--========================
-- Estado y configuración
--========================
local aimlockEnabled = false
local maxTargetDistance = 200
local aimPartNamePriority = { "Head", "UpperTorso", "HumanoidRootPart" }
-- Solo jugadores reales
local function isValidTarget(character)
if character == localPlayer.Character then return false end
local humanoid = character:FindFirstChildOfClass("Humanoid")
if not humanoid or humanoid.Health <= 0 then return false end
local targetPlayer = Players:GetPlayerFromCharacter(character)
if not targetPlayer then return false end -- solo jugadores
-- Excluir compañeros de equipo si el juego usa Teams
if localPlayer.Team and targetPlayer.Team == localPlayer.Team then
return false
end
return true
end
local function getAimPart(character)
for _, partName in ipairs(aimPartNamePriority) do
local part = character:FindFirstChild(partName)
if part then return part end
end
return character:FindFirstChild("HumanoidRootPart")
end
local function getNearestTarget()
local camPos = camera.CFrame.Position
local nearestChar, nearestDist = nil, math.huge
for _, plr in ipairs(Players:GetPlayers()) do
if plr ~= localPlayer and plr.Character and isValidTarget(plr.Character) then
local part = getAimPart(plr.Character)
if part then
local dist = (part.Position - camPos).Magnitude
if dist < nearestDist and dist <= maxTargetDistance then
nearestDist = dist
nearestChar = plr.Character
end
end
end
end
return nearestChar
end
local function aimCameraAt(targetChar)
if not targetChar then return end
local aimPart = getAimPart(targetChar)
if not aimPart then return end
local camPos = camera.CFrame.Position
camera.CFrame = CFrame.new(camPos, aimPart.Position)
end
-- Loop de actualización
local heartbeatConn
local function startAimlock()
if heartbeatConn then return end
heartbeatConn = RunService.RenderStepped:Connect(function()
if aimlockEnabled then
local target = getNearestTarget()
if target then aimCameraAt(target) end
end
end)
end
local function stopAimlock()
if heartbeatConn then
heartbeatConn:Disconnect()
heartbeatConn = nil
end
end
-- Toggle UI
local function setToggleState(state)
aimlockEnabled = state
if aimlockEnabled then
toggleBtn.Text = "ON"
toggleBtn.BackgroundColor3 = Color3.fromRGB(0, 180, 80)
startAimlock()
else
toggleBtn.Text = "OFF"
toggleBtn.BackgroundColor3 = Color3.fromRGB(180, 0, 0)
stopAimlock()
end
end
toggleBtn.MouseButton1Click:Connect(function()
setToggleState(not aimlockEnabled)
end)
-- Estado inicial
setToggleState(false)
-- Tecla rápida (ejemplo: G)
UserInputService.InputBegan:Connect(function(input, gp)
if gp then return end
if input.KeyCode == Enum.KeyCode.G then
setToggleState(not aimlockEnabled)
end
end)
-- Aimlock Toggle UI para juegos de battlegrounds (solo jugadores reales)
-- Colocar como LocalScript en StarterPlayerScripts
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local localPlayer = Players.LocalPlayer
local camera = workspace.CurrentCamera
--========================
-- UI: Frame movible + Toggle
--========================
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "AimlockUI"
screenGui.ResetOnSpawn = false
screenGui.IgnoreGuiInset = true
screenGui.Parent = localPlayer:WaitForChild("PlayerGui")
local frame = Instance.new("Frame")
frame.Size = UDim2.new(0, 140, 0, 60)
frame.Position = UDim2.new(0, 30, 0, 200)
frame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
frame.Active = true
frame.Draggable = true
frame.Parent = screenGui
local uiCorner = Instance.new("UICorner")
uiCorner.CornerRadius = UDim.new(0, 10)
uiCorner.Parent = frame
local title = Instance.new("TextLabel")
title.Size = UDim2.new(1, -10, 0, 24)
title.Position = UDim2.new(0, 5, 0, 5)
title.BackgroundTransparency = 1
title.Text = "Aimlock"
title.TextColor3 = Color3.fromRGB(255, 255, 255)
title.TextScaled = true
title.Font = Enum.Font.GothamBold
title.Parent = frame
local toggleBtn = Instance.new("TextButton")
toggleBtn.Size = UDim2.new(1, -20, 0, 26)
toggleBtn.Position = UDim2.new(0, 10, 0, 30)
toggleBtn.BackgroundColor3 = Color3.fromRGB(180, 0, 0) -- OFF rojo
toggleBtn.Text = "OFF"
toggleBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
toggleBtn.TextScaled = true
toggleBtn.Font = Enum.Font.GothamBold
toggleBtn.Parent = frame
local btnCorner = Instance.new("UICorner")
btnCorner.CornerRadius = UDim.new(0, 8)
btnCorner.Parent = toggleBtn
--========================
-- Estado y configuración
--========================
local aimlockEnabled = false
local maxTargetDistance = 200
local aimPartNamePriority = { "Head", "UpperTorso", "HumanoidRootPart" }
-- Solo jugadores reales
local function isValidTarget(character)
if character == localPlayer.Character then return false end
local humanoid = character:FindFirstChildOfClass("Humanoid")
if not humanoid or humanoid.Health <= 0 then return false end
end
local function getAimPart(character)
for _, partName in ipairs(aimPartNamePriority) do
local part = character:FindFirstChild(partName)
if part then return part end
end
return character:FindFirstChild("HumanoidRootPart")
end
local function getNearestTarget()
local camPos = camera.CFrame.Position
local nearestChar, nearestDist = nil, math.huge
end
local function aimCameraAt(targetChar)
if not targetChar then return end
local aimPart = getAimPart(targetChar)
if not aimPart then return end
local camPos = camera.CFrame.Position
camera.CFrame = CFrame.new(camPos, aimPart.Position)
end
-- Loop de actualización
local heartbeatConn
local function startAimlock()
if heartbeatConn then return end
heartbeatConn = RunService.RenderStepped:Connect(function()
if aimlockEnabled then
local target = getNearestTarget()
if target then aimCameraAt(target) end
end
end)
end
local function stopAimlock()
if heartbeatConn then
heartbeatConn:Disconnect()
heartbeatConn = nil
end
end
-- Toggle UI
local function setToggleState(state)
aimlockEnabled = state
if aimlockEnabled then
toggleBtn.Text = "ON"
toggleBtn.BackgroundColor3 = Color3.fromRGB(0, 180, 80)
startAimlock()
else
toggleBtn.Text = "OFF"
toggleBtn.BackgroundColor3 = Color3.fromRGB(180, 0, 0)
stopAimlock()
end
end
toggleBtn.MouseButton1Click:Connect(function()
setToggleState(not aimlockEnabled)
end)
-- Estado inicial
setToggleState(false)
-- Tecla rápida (ejemplo: G)
UserInputService.InputBegan:Connect(function(input, gp)
if gp then return end
if input.KeyCode == Enum.KeyCode.G then
setToggleState(not aimlockEnabled)
end
end)