
KeylessUniversal

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local player = Players.LocalPlayer
local FOLLOW_DISTANCE = 6
local ATTACK_DISTANCE = 10
local ATTACK_DELAY = 0.18
local JUMP_MIN = 0.7
local JUMP_MAX = 1.8
local character
local humanoid
local root
local equippedTool
local attacking = false
local nextJump = 0
local function setupCharacter(char)
character = char
humanoid = char:WaitForChild("Humanoid")
root = char:WaitForChild("HumanoidRootPart")
equippedTool = nil
end
if player.Character then
setupCharacter(player.Character)
end
player.CharacterAdded:Connect(setupCharacter)
local function isDamageTool(tool)
if not tool:IsA("Tool") then
return false
end
-- Look for common damage indicators
if tool:FindFirstChild("Handle") then
return true
end
if tool:FindFirstChildWhichIsA("RemoteEvent", true) then
return true
end
return true
end
local function getClosestPlayer()
if not root then
return nil
end
local closest = nil
local closestDistance = math.huge
for _, target in ipairs(Players:GetPlayers()) do
if target ~= player and target.Character then
local targetHumanoid = target.Character:FindFirstChildOfClass("Humanoid")
local targetRoot = target.Character:FindFirstChild("HumanoidRootPart")
if targetHumanoid and targetRoot and targetHumanoid.Health > 0 then
local distance = (targetRoot.Position - root.Position).Magnitude
if distance < closestDistance then
closestDistance = distance
closest = target
end
end
end
end
return closest, closestDistance
end
local function attack()
if not equippedTool or not equippedTool.Parent then
return
end
-- Uses the Tool's normal activation/damage system
pcall(function()
equippedTool:Activate()
end)
end
local function equipDetectedTool(tool)
if tool:IsA("Tool") and isDamageTool(tool) then
equippedTool = tool
end
end
local function checkTool(tool)
if tool:IsA("Tool") then
tool.Equipped:Connect(function()
if isDamageTool(tool) then
equippedTool = tool
end
end)
tool.Unequipped:Connect(function()
if equippedTool == tool then
equippedTool = nil
end
end)
if tool.Parent == character then
equippedTool = tool
end
end
end
local function monitorTools()
if not character then
return
end
for _, tool in ipairs(character:GetChildren()) do
checkTool(tool)
end
for _, tool in ipairs(player.Backpack:GetChildren()) do
checkTool(tool)
end
end
player.Backpack.ChildAdded:Connect(function(child)
checkTool(child)
end)
if character then
character.ChildAdded:Connect(function(child)
checkTool(child)
end)
end
monitorTools()
RunService.Heartbeat:Connect(function()
if not character or not humanoid or not root then
return
end
if humanoid.Health <= 0 then
return
end
if not equippedTool or equippedTool.Parent ~= character then
return
end
local target, distance = getClosestPlayer()
if not target or not target.Character then
return
end
local targetRoot = target.Character:FindFirstChild("HumanoidRootPart")
if not targetRoot then
return
end
-- Follow the closest player
if distance > FOLLOW_DISTANCE then
humanoid:MoveTo(targetRoot.Position)
else
-- Stay around the target instead of standing directly inside them
local direction = (root.Position - targetRoot.Position)
if direction.Magnitude < 1 then
direction = Vector3.new(0, 0, 1)
end
local desiredPosition =
targetRoot.Position + direction.Unit * FOLLOW_DISTANCE
humanoid:MoveTo(desiredPosition)
end
-- Random jumping
if os.clock() >= nextJump then
if math.random(1, 100) <= 70 then
humanoid.Jump = true
end
nextJump = os.clock() + math.random() * (JUMP_MAX - JUMP_MIN) + JUMP_MIN
end
-- Attack when close enough
if distance <= ATTACK_DISTANCE and not attacking then
attacking = true
task.spawn(function()
attack()
task.wait(ATTACK_DELAY)
attacking = false
end)
end
end)
![[KEYLESS] Moondiety Script | 17+ supported Games](https://scriptblox.com/images/sb/0-1753093706828.png)


the code is mid cutted