-- Sistema básico de Aiming (para bots/NPCs en tu juego)
local Aimbot = {}
-- Función principal: Hace que un personaje apunte hacia un objetivo
function Aimbot.AimAt(targetPosition, character, aimPartName)
if not character or not targetPosition then
return
end
local aimPart = character:FindFirstChild(aimPartName or "Head") or character.PrimaryPart
if not aimPart then return end
-- Dirección desde el arma o cabeza hacia el objetivo
local direction = (targetPosition - aimPart.Position).Unit
-- Rotar el personaje o el arma hacia el objetivo
local lookAtCFrame = CFrame.lookAt(aimPart.Position, aimPart.Position + direction)
-- Aplicar rotación suave (opcional)
aimPart.CFrame = aimPart.CFrame:Lerp(lookAtCFrame, 0.3) -- 0.3 = velocidad de giro
end
-- Ejemplo de uso en un Loop (RunService)
local RunService = game:GetService("RunService")
RunService.Heartbeat:Connect(function()
for _, bot in ipairs(workspace.Bots:GetChildren()) do -- Asume que tienes bots en una carpeta
local target = workspace.Players:FindFirstChild("PlayerName") -- o el jugador más cercano
if target and target:FindFirstChild("HumanoidRootPart") then
local targetPos = target.HumanoidRootPart.Position
-- Opcional: Predecir movimiento (lead target)
if target.HumanoidRootPart.Velocity.Magnitude > 5 then
targetPos = targetPos + (target.HumanoidRootPart.Velocity * 0.1) -- Ajusta el 0.1
end
Aimbot.AimAt(targetPos, bot, "Head") -- o "UpperTorso", etc.
end
end
end)
Comments
No comments yet
Be the first to share your thoughts!