--// AUTO ATTACK GUI (RUN ALL-IN-ONE)
--// รันได้เลยใน executor
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local VirtualInputManager = game:GetService("VirtualInputManager")
local player = Players.LocalPlayer
--========================
-- REMOVE OLD GUI
--========================
pcall(function()
game.CoreGui.AutoAttackGUI:Destroy()
end)
--========================
-- SETTINGS
--========================
local Enabled = false
local Range = 10
local Dragging = false
--========================
-- GUI
--========================
local gui = Instance.new("ScreenGui")
gui.Name = "AutoAttackGUI"
gui.Parent = game.CoreGui
gui.ResetOnSpawn = false
local frame = Instance.new("Frame")
frame.Parent = gui
frame.Size = UDim2.new(0,230,0,170)
frame.Position = UDim2.new(0.03,0,0.35,0)
frame.BackgroundColor3 = Color3.fromRGB(20,20,20)
frame.BorderSizePixel = 0
frame.Active = true
frame.Draggable = true
Instance.new("UICorner", frame).CornerRadius = UDim.new(0,12)
local title = Instance.new("TextLabel")
title.Parent = frame
title.Size = UDim2.new(1,0,0,35)
title.BackgroundTransparency = 1
title.Text = "AUTO ATTACK"
title.Font = Enum.Font.GothamBold
title.TextSize = 20
title.TextColor3 = Color3.new(1,1,1)
local toggle = Instance.new("TextButton")
toggle.Parent = frame
toggle.Size = UDim2.new(0.8,0,0,40)
toggle.Position = UDim2.new(0.1,0,0.3,0)
toggle.BackgroundColor3 = Color3.fromRGB(170,40,40)
toggle.Text = "OFF"
toggle.TextColor3 = Color3.new(1,1,1)
toggle.Font = Enum.Font.GothamBold
toggle.TextSize = 18
Instance.new("UICorner", toggle).CornerRadius = UDim.new(0,10)
local rangeText = Instance.new("TextLabel")
rangeText.Parent = frame
rangeText.Size = UDim2.new(1,0,0,25)
rangeText.Position = UDim2.new(0,0,0.62,0)
rangeText.BackgroundTransparency = 1
rangeText.Text = "Range : 10"
rangeText.Font = Enum.Font.Gotham
rangeText.TextSize = 16
rangeText.TextColor3 = Color3.new(1,1,1)
local slider = Instance.new("Frame")
slider.Parent = frame
slider.Size = UDim2.new(0.8,0,0,18)
slider.Position = UDim2.new(0.1,0,0.82,0)
slider.BackgroundColor3 = Color3.fromRGB(50,50,50)
Instance.new("UICorner", slider).CornerRadius = UDim.new(1,0)
local fill = Instance.new("Frame")
fill.Parent = slider
fill.Size = UDim2.new(0.2,0,1,0)
fill.BackgroundColor3 = Color3.fromRGB(255,0,0)
Instance.new("UICorner", fill).CornerRadius = UDim.new(1,0)
--========================
-- RANGE CIRCLE
--========================
local circle = Instance.new("Part")
circle.Shape = Enum.PartType.Cylinder
circle.Anchored = true
circle.CanCollide = false
circle.Material = Enum.Material.Neon
circle.Color = Color3.fromRGB(255,0,0)
circle.Transparency = 1
circle.Size = Vector3.new(0.15, Range * 2, Range * 2)
circle.Parent = workspace
--========================
-- TOGGLE
--========================
toggle.MouseButton1Click:Connect(function()
Enabled = not Enabled
if Enabled then
toggle.Text = "ON"
toggle.BackgroundColor3 = Color3.fromRGB(40,170,40)
else
toggle.Text = "OFF"
toggle.BackgroundColor3 = Color3.fromRGB(170,40,40)
end
end)
--========================
-- SLIDER
--========================
slider.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
Dragging = true
end
end)
UIS.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
Dragging = false
end
end)
UIS.InputChanged:Connect(function(input)
if Dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
local percent = math.clamp(
(input.Position.X - slider.AbsolutePosition.X)
/ slider.AbsoluteSize.X,
0,
1
)
fill.Size = UDim2.new(percent,0,1,0)
Range = math.floor(1 + (49 * percent))
rangeText.Text = "Range : "..Range
circle.Size = Vector3.new(
0.15,
Range * 2,
Range * 2
)
end
end)
--========================
-- AUTO ATTACK
--========================
RunService.RenderStepped:Connect(function()
local char = player.Character
if not char then return end
local hrp = char:FindFirstChild("HumanoidRootPart")
if not hrp then return end
-- UPDATE CIRCLE
circle.CFrame =
CFrame.new(hrp.Position)
* CFrame.Angles(0,0,math.rad(90))
circle.Transparency = Enabled and 0.45 or 1
if not Enabled then return end
local world = workspace:FindFirstChild("World")
if not world then return end
local enemiesFolder = world:FindFirstChild("Enemies")
if not enemiesFolder then return end
for _, enemy in pairs(enemiesFolder:GetChildren()) do
local enemyRoot = enemy:FindFirstChild("HumanoidRootPart")
local humanoid = enemy:FindFirstChildOfClass("Humanoid")
if enemyRoot and humanoid and humanoid.Health > 0 then
local distance =
(enemyRoot.Position - hrp.Position).Magnitude
if distance <= Range then
-- หันไปหาศัตรู
hrp.CFrame = CFrame.new(
hrp.Position,
enemyRoot.Position
)
-- คลิกโจมตี
VirtualInputManager:SendMouseButtonEvent(
0,
0,
0,
true,
game,
0
)
VirtualInputManager:SendMouseButtonEvent(
0,
0,
0,
false,
game,
0
)
task.wait(0.12)
end
end
end
end)
Comments
unsure what this is