
KeylessUniversal

-- 自动攻击脚本(基于抓包数据:Normal Slap 道具)
local Players = game:GetService("Players")
local player = Players.LocalPlayer
-- ========== UI 构建 ==========
local gui = Instance.new("ScreenGui")
gui.Name = "AutoSlapGUI"
gui.ResetOnSpawn = false
gui.Parent = player:WaitForChild("PlayerGui")
local frame = Instance.new("Frame")
frame.Size = UDim2.new(0, 220, 0, 160)
frame.Position = UDim2.new(0, 10, 0, 10) -- 左上角固定
frame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
frame.BorderSizePixel = 0
local frameStroke = Instance.new("UIStroke")
frameStroke.Color = Color3.new(0, 0, 0) -- 黑色边框
frameStroke.Thickness = 2
frameStroke.Parent = frame
frame.Parent = gui
-- 标题
local title = Instance.new("TextLabel")
title.Size = UDim2.new(1, 0, 0, 30)
title.Text = "Auto Slap"
title.TextColor3 = Color3.new(1, 1, 1)
title.BackgroundTransparency = 1
title.Font = Enum.Font.SourceSansBold
title.TextSize = 18
title.Parent = frame
-- 开关按钮
local toggleBtn = Instance.new("TextButton")
toggleBtn.Size = UDim2.new(0, 100, 0, 30)
toggleBtn.Position = UDim2.new(0.5, -50, 0, 40)
toggleBtn.Text = "开启"
toggleBtn.TextColor3 = Color3.new(1, 1, 1)
toggleBtn.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
toggleBtn.BorderSizePixel = 0
local btnStroke = Instance.new("UIStroke")
btnStroke.Color = Color3.new(0, 0, 0)
btnStroke.Thickness = 1
btnStroke.Parent = toggleBtn
toggleBtn.Parent = frame
-- 范围标签
local rangeLabel = Instance.new("TextLabel")
rangeLabel.Size = UDim2.new(0, 60, 0, 30)
rangeLabel.Position = UDim2.new(0, 10, 0, 80)
rangeLabel.Text = "范围:"
rangeLabel.TextColor3 = Color3.new(1, 1, 1)
rangeLabel.BackgroundTransparency = 1
rangeLabel.TextSize = 14
rangeLabel.Parent = frame
-- 范围输入框
local rangeBox = Instance.new("TextBox")
rangeBox.Size = UDim2.new(0, 80, 0, 30)
rangeBox.Position = UDim2.new(0, 70, 0, 80)
rangeBox.Text = "50"
rangeBox.TextColor3 = Color3.new(1, 1, 1)
rangeBox.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
rangeBox.BorderSizePixel = 0
local boxStroke = Instance.new("UIStroke")
boxStroke.Color = Color3.new(0, 0, 0)
boxStroke.Thickness = 1
boxStroke.Parent = rangeBox
rangeBox.Parent = frame
-- 当前范围显示
local rangeDisplay = Instance.new("TextLabel")
rangeDisplay.Size = UDim2.new(0, 40, 0, 30)
rangeDisplay.Position = UDim2.new(0, 160, 0, 80)
rangeDisplay.Text = "50"
rangeDisplay.TextColor3 = Color3.new(1, 1, 1)
rangeDisplay.BackgroundTransparency = 1
rangeDisplay.TextSize = 14
rangeDisplay.Parent = frame
-- ========== 状态变量 ==========
local isRunning = false
local range = 50
-- ========== 辅助函数 ==========
local function getSlapTool()
local tool = player.Backpack:FindFirstChild("Normal Slap")
if not tool and player.Character then
tool = player.Character:FindFirstChild("Normal Slap")
end
return tool
end
local function attackTarget(target)
local tool = getSlapTool()
if not tool then return end
local event = tool:FindFirstChild("Event")
if not event then return end
local pos = target:FindFirstChild("HumanoidRootPart")
if not pos then return end
event:FireServer("slash", target, pos.Position)
end
-- ========== 主循环 ==========
local function autoSlapLoop()
while wait(0.5) do
if not isRunning then break end
local myChar = player.Character
if not myChar then continue end
local myRoot = myChar:FindFirstChild("HumanoidRootPart")
if not myRoot then continue end
local myPos = myRoot.Position
local nearestTarget = nil
local nearestDist = range + 1
for _, otherPlayer in ipairs(Players:GetPlayers()) do
if otherPlayer ~= player then
local char = otherPlayer.Character
if char then
local hrp = char:FindFirstChild("HumanoidRootPart")
local hum = char:FindFirstChild("Humanoid")
if hrp and hum and hum.Health > 0 then
local dist = (hrp.Position - myPos).Magnitude
if dist <= range and dist < nearestDist then
nearestTarget = char
nearestDist = dist
end
end
end
end
end
if nearestTarget then
attackTarget(nearestTarget)
end
end
end
-- ========== 事件绑定 ==========
toggleBtn.MouseButton1Click:Connect(function()
isRunning = not isRunning
toggleBtn.Text = isRunning and "关闭" or "开启"
if isRunning then
coroutine.wrap(autoSlapLoop)()
end
end)
rangeBox.FocusLost:Connect(function()
local num = tonumber(rangeBox.Text)
if num then
range = num
rangeDisplay.Text = tostring(num)
else
rangeBox.Text = tostring(range) -- 输入无效时恢复
end
end)
-- 初始化显示
rangeDisplay.Text = tostring(range)No comments yet for this script.



