Further enhance this roblox script, and add a bunch more features: --[[ Autoblock V.3…
- User
Further enhance this roblox script, and add a bunch more features:
code - Assistant
Further enhance this roblox script, and add a bunch more features:
--[[
Autoblock V.3
Super Advanced Auto Block & Swing Script for Saber Showdown
Enhanced with an advanced auto-block framework for improved performance and functionality
Author: Keperman209
Version: 3.0
Date: 09.24.2024
--]]
-- === Services ===
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local VirtualInputManager = game:GetService("VirtualInputManager")
local CollectionService = game:GetService("CollectionService")
local Debris = game:GetService("Debris")
local Workspace = workspace
-- === Constants ===
local LOCAL_PLAYER = Players.LocalPlayer
local CAMERA = Workspace.CurrentCamera
local ATTACK_HITBOX_TAG = "AttackHitbox"
local BLOCK_DIRECTIONS = {
Forward = 1,
Right = 2,
Backward = 3,
Left = 4
}
-- === Remotes ===
local LightsaberRemotes = ReplicatedStorage:WaitForChild("LightsaberRemotes")
local BlockRemote = LightsaberRemotes:WaitForChild("Block")
local UnblockRemote = LightsaberRemotes:WaitForChild("Unblock")
local UpdateBlockDirectionRemote = LightsaberRemotes:WaitForChild("UpdateBlockDirection")
-- === Settings ===
local Settings = {
-- Blocking Settings
blockDistances = { -- Max distance to attempt a block per attack type
Slap = 10, -- Slaps require closer proximity
Default = 15 -- Default distance for other attacks
},
autoBlockEnabled = true, -- Enable/Disable dynamic auto-blocking
blockCooldown = 0.5, -- General cooldown between blocks (seconds)
attackBlockCooldowns = { -- Cooldown between blocks per attack type (seconds)
Slap = 0.2,
Default = 0.5
},
attackTypes = { -- Attack animation IDs
Slap = 12625891544,
SlappedLegs = 12671715182,
SlappedArms = 12625896358,
Punch = 12625897000, -- Example attack ID
Kick = 12625897500, -- Example attack ID
KickUp = 12625897944, -- Added KickUp
KickBack = 12625899752 -- Added KickBack
},
-- Counter Attacking Settings
autoCounterEnabled = true, -- Enable/Disable auto counter attacks
autoCounterDistance = 10, -- Distance within which to auto counter
counterCooldown = 1.5, -- Cooldown between counters (seconds)
counterKey = Enum.KeyCode.E, -- Key to use for countering
-- Reaction Settings
reactionTimeThreshold = 0.2, -- Threshold for reaction time (in seconds)
predictionFactor = 0.5, -- Factor for predicting enemy movements (0-1)
-- Slap Lag Handling
slapLagCompensation = 0.2, -- Additional delay to compensate for lag in slap attacks
-- Aim-Lock Directional Block Settings
aimLockEnabled = true, -- Enable/Disable aim-lock directional blocking
aimLockSmoothness = 0.1, -- Smoothness factor for direction adjustment
-- Slap Blocking Specific Settings
slap = {
slapCooldown = 1.0, -- Cooldown between handling slap blocks (seconds)
autoSlapEnabled = true, -- Enable/Disable auto countering slaps
autoSlapDistance = 8, -- Distance within which to auto counter slaps
slapTimerESPEnabled = true, -- Enable/Disable visual cooldown indicator for slaps
},
-- UI Settings
ui = {
ScreenGuiName = "AutoBlockUI_V3",
-- Black Box Frame
BlackBox = {
Size = UDim2.new(0.25, 0, 0.2, 0),
Position = UDim2.new(0.375, 0, 0.8, 0),
BackgroundColor = Color3.fromRGB(30, 30, 30),
BackgroundTransparency = 0.15,
CornerRadius = 12,
BorderColor = Color3.fromRGB(255, 255, 255),
BorderSizePixel = 2
},
-- Loading Bar
LoadingBar = {
Size = UDim2.new(1, -20, 0.25, -10),
Position = UDim2.new(0, 10, 0.1, 10),
BackgroundColorActive = Color3.fromRGB(0, 255, 0),
BackgroundColorInactive = Color3.fromRGB(255, 0, 0),
BackgroundTransparency = 0.3,
CornerRadius = 8
},
-- Message Box
MessageBox = {
Size = UDim2.new(1, -20, 0.4, -10),
Position = UDim2.new(0, 10, 0.35, 10),
BackgroundTransparency = 1,
TextColor = Color3.fromRGB(255, 255, 255),
TextScaled = true,
Font = Enum.Font.GothamSemibold,
Text = "Press 'Q' to toggle Auto Block",
TextStrokeColor = Color3.fromRGB(0, 0, 0),
TextStrokeTransparency = 0.5
},
-- Direction Indicator
DirectionIndicator = {
Size = UDim2.new(0.2, -10, 0.5, -10),
Position = UDim2.new(0.4, 10, 0.5, 10),
BackgroundColor = Color3.fromRGB(50, 50, 50),
BackgroundTransparency = 0.3,
CornerRadius = 8,
Image = nil -- Placeholder for directional icons
},
-- Toggle Button
ToggleButton = {
Size = UDim2.new(0.3, -20, 0.25, -10),
Position = UDim2.new(0.35, 10, 0.7, 10),
BackgroundColor = Color3.fromRGB(70, 130, 180),
BackgroundTransparency = 0.3,
CornerRadius = 8,
TextColor = Color3.fromRGB(255, 255, 255),
TextScaled = true,
Font = Enum.Font.GothamBold,
Text = "Disable Auto Block",
TextStrokeColor = Color3.fromRGB(0, 0, 0),
TextStrokeTransparency = 0.5
},
-- Slap Timer (ESP) Visual Indicator
SlapTimer = {
Size = UDim2.new(0.3, -20, 0.05, -10),
Position = UDim2.new(0.35, 10, 0.8, 10),
BackgroundColor = Color3.fromRGB(255, 0, 0),
BackgroundTransparency = 0.3,
CornerRadius = 8,
Visible = false,
TextColor = Color3.fromRGB(255, 255, 255),
TextScaled = true,
Font = Enum.Font.GothamSemibold,
Text = "Slap Cooldown: 0s",
TextStrokeColor = Color3.fromRGB(0, 0, 0),
TextStrokeTransparency = 0.5
}
},
-- Debris Settings
debrisLifetime = 300, -- Time in seconds before debris is removed (e.g., hitboxes)
}
-- === Inverse Mapping for Attack Types ===
local attackTypesInverse = {}
for attack, id in pairs(Settings.attackTypes) do
attackTypesInverse[tostring(id)] = attack
end
-- === State Tracking ===
local State = {
isBlocking = false,
lastBlockTime = {}, -- [player.UserId] = timestamp
lastCounterTime = {}, -- [player.UserId] = timestamp
currentBlockDirection = BLOCK_DIRECTIONS.Forward,
autoBlockEnabled = Settings.autoBlockEnabled,
lastSlapBlockTime = {}, -- [player.UserId] = timestamp
canSlap = {}, -- [player.UserId] = boolean indicating if player can slap
}
-- === UI Elements ===
local UI = {
ScreenGui = nil,
BlackBox = nil,
LoadingBar = nil,
MessageBox = nil,
DirectionIndicator = nil,
ToggleButton = nil,
SlapTimer = nil
}
-- === Helper Functions ===
-- Utility: Print with timestamp
local function debugPrint(message)
print(string.format("[%s] %s", os.date("%H:%M:%S"), message))
end
-- UI: Create Rounded Corners for Frames
local function addRoundedCorners(frame, radius)
local corner = Instance.new("UICorner")
corner.CornerRadius = UDim.new(0, radius)
corner.Parent = frame
return corner
end
-- UI: Setup the User Interface
local function setupUI()
local screenGui = Instance.new("ScreenGui")
screenGui.Name = Settings.ui.ScreenGuiName
screenGui.Parent = LOCAL_PLAYER:WaitForChild("PlayerGui")
screenGui.ResetOnSpawn = false
screenGui.DisplayOrder = 1000 -- Ensure it's on top
-- Black Box Frame
local blackBox = Instance.new("Frame")
blackBox.Size = Settings.ui.BlackBox.Size
blackBox.Position = Settings.ui.BlackBox.Position
blackBox.BackgroundColor3 = Settings.ui.BlackBox.BackgroundColor
blackBox.BackgroundTransparency = Settings.ui.BlackBox.BackgroundTransparency
blackBox.BorderSizePixel = Settings.ui.BlackBox.BorderSizePixel
blackBox.BorderColor3 = Settings.ui.BlackBox.BorderColor
blackBox.Parent = screenGui
addRoundedCorners(blackBox, Settings.ui.BlackBox.CornerRadius)
-- Loading Bar Background
local loadingBarBackground = Instance.new("Frame")
loadingBarBackground.Size = Settings.ui.LoadingBar.Size
loadingBarBackground.Position = Settings.ui.LoadingBar.Position
loadingBarBackground.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
loadingBarBackground.BackgroundTransparency = 0.3
loadingBarBackground.BorderSizePixel = 0
loadingBarBackground.Parent = blackBox
addRoundedCorners(loadingBarBackground, Settings.ui.LoadingBar.CornerRadius or 8)
-- Loading Bar Foreground
local loadingBar = Instance.new("Frame")
loadingBar.Size = UDim2.new(0, 0, 1, 0) -- Start empty
loadingBar.Position = UDim2.new(0, 0, 0, 0)
loadingBar.BackgroundColor3 = Settings.ui.LoadingBar.BackgroundColorInactive
loadingBar.BorderSizePixel = 0
loadingBar.Parent = loadingBarBackground
addRoundedCorners(loadingBar, Settings.ui.LoadingBar.CornerRadius or 8)
-- Message Box
local messageBox = Instance.new("TextLabel")
messageBox.Size = Settings.ui.MessageBox.Size
messageBox.Position = Settings.ui.MessageBox.Position
messageBox.BackgroundTransparency = Settings.ui.MessageBox.BackgroundTransparency
messageBox.TextColor3 = Settings.ui.MessageBox.TextColor
messageBox.TextScaled = Settings.ui.MessageBox.TextScaled
messageBox.Text = Settings.ui.MessageBox.Text
messageBox.Font = Settings.ui.MessageBox.Font
messageBox.TextStrokeColor3 = Settings.ui.MessageBox.TextStrokeColor
messageBox.TextStrokeTransparency = Settings.ui.MessageBox.TextStrokeTransparency
messageBox.BorderSizePixel = 0
messageBox.Parent = blackBox
-- Direction Indicator
local directionIndicator = Instance.new("Frame")
directionIndicator.Size = Settings.ui.DirectionIndicator.Size
directionIndicator.Position = Settings.ui.DirectionIndicator.Position
directionIndicator.BackgroundColor3 = Settings.ui.DirectionIndicator.BackgroundColor
directionIndicator.BackgroundTransparency = Settings.ui.DirectionIndicator.BackgroundTransparency
directionIndicator.BorderSizePixel = 0
directionIndicator.Parent = blackBox
addRoundedCorners(directionIndicator, Settings.ui.DirectionIndicator.CornerRadius or 8)
-- Direction Indicator Icon
local directionIcon = Instance.new("ImageLabel")
directionIcon.Size = UDim2.new(0.8, 0, 0.8, 0)
directionIcon.Position = UDim2.new(0.1, 0, 0.1, 0)
directionIcon.BackgroundTransparency = 1
directionIcon.Image = "rbxassetid://4542562196" -- Placeholder: Forward Arrow Icon
directionIcon.Visible = true
directionIcon.Parent = directionIndicator
-- Toggle Button
local toggleButton = Instance.new("TextButton")
toggleButton.Size = Settings.ui.ToggleButton.Size
toggleButton.Position = Settings.ui.ToggleButton.Position
toggleButton.BackgroundColor3 = Settings.ui.ToggleButton.BackgroundColor
toggleButton.BackgroundTransparency = Settings.ui.ToggleButton.BackgroundTransparency
toggleButton.BorderSizePixel = 0
toggleButton.TextColor3 = Settings.ui.ToggleButton.TextColor
toggleButton.TextScaled = Settings.ui.ToggleButton.TextScaled
toggleButton.Font = Settings.ui.ToggleButton.Font
toggleButton.Text = Settings.ui.ToggleButton.Text
toggleButton.TextStrokeColor3 = Settings.ui.ToggleButton.TextStrokeColor
toggleButton.TextStrokeTransparency = Settings.ui.ToggleButton.TextStrokeTransparency
toggleButton.Parent = blackBox
addRoundedCorners(toggleButton, Settings.ui.ToggleButton.CornerRadius or 8)
-- Toggle Button Hover Effect
toggleButton.MouseEnter:Connect(function()
toggleButton.BackgroundColor3 = Color3.fromRGB(100, 149, 237)
end)
toggleButton.MouseLeave:Connect(function()
toggleButton.BackgroundColor3 = State.autoBlockEnabled and Settings.ui.ToggleButton.BackgroundColor or Color3.fromRGB(169, 169, 169)
end)
-- Toggle Button Functionality
toggleButton.MouseButton1Click:Connect(function()
State.autoBlockEnabled = not State.autoBlockEnabled
toggleButton.Text = State.autoBlockEnabled and "Disable Auto Block" or "Enable Auto Block"
toggleButton.BackgroundColor3 = State.autoBlockEnabled and Settings.ui.ToggleButton.BackgroundColor or Color3.fromRGB(169, 169, 169)
UI.MessageBox.Text = State.autoBlockEnabled and "Auto Block Enabled" or "Auto Block Disabled"
debugPrint("Auto Block " .. (State.autoBlockEnabled and "Enabled" or "Disabled"))
end)
-- Slap Timer (ESP) Visual Indicator
local slapTimer = Instance.new("TextLabel")
slapTimer.Size = Settings.ui.SlapTimer.Size
slapTimer.Position = Settings.ui.SlapTimer.Position
slapTimer.BackgroundColor3 = Settings.ui.SlapTimer.BackgroundColor
slapTimer.BackgroundTransparency = Settings.ui.SlapTimer.BackgroundTransparency
slapTimer.BorderSizePixel = 0
slapTimer.TextColor3 = Settings.ui.SlapTimer.TextColor
slapTimer.TextScaled = Settings.ui.SlapTimer.TextScaled
slapTimer.Font = Settings.ui.SlapTimer.Font
slapTimer.Text = Settings.ui.SlapTimer.Text
slapTimer.TextStrokeColor3 = Settings.ui.SlapTimer.TextStrokeColor
slapTimer.TextStrokeTransparency = Settings.ui.SlapTimer.TextStrokeTransparency
slapTimer.Visible = Settings.ui.SlapTimer.Visible
slapTimer.Parent = blackBox
addRoundedCorners(slapTimer, Settings.ui.SlapTimer.CornerRadius or 8)
-- Assign UI Elements to the UI Table
UI.ScreenGui = screenGui
UI.BlackBox = blackBox
UI.LoadingBar = loadingBar
UI.MessageBox = messageBox
UI.DirectionIndicator = directionIndicator
UI.ToggleButton = toggleButton
UI.SlapTimer = slapTimer
end
-- Blocking: Start Blocking
local function startBlocking()
if not State.isBlocking then
State.isBlocking = true
BlockRemote:FireServer()
UI.MessageBox.Text = "Blocking Active"
UI.LoadingBar.BackgroundColor3 = Settings.ui.LoadingBar.BackgroundColorActive
UI.LoadingBar:TweenSize(UDim2.new(1, 0, 1, 0), "Out", "Quad", 0.2, true)
debugPrint("Blocking started")
end
end
-- Blocking: Stop Blocking
local function stopBlocking()
if State.isBlocking then
State.isBlocking = false
UnblockRemote:FireServer()
UI.MessageBox.Text = Settings.autoBlockEnabled and "Auto Block Enabled" or "Auto Block Disabled"
UI.LoadingBar.BackgroundColor3 = Settings.ui.LoadingBar.BackgroundColorInactive
UI.LoadingBar:TweenSize(UDim2.new(0, 0, 1, 0), "Out", "Quad", 0.2, true)
debugPrint("Blocking stopped")
end
end
-- Blocking: Toggle Blocking State
local function toggleBlocking()
if State.isBlocking then
stopBlocking()
else
startBlocking()
end
end
-- Prediction: Predict Enemy Movement
local function predictEnemyMovement(enemy)
local enemyCharacter = enemy.Character
if not enemyCharacter then return nil end
local enemyHRP = enemyCharacter:FindFirstChild("HumanoidRootPart")
if not enemyHRP then return nil end
local velocity = enemyHRP.Velocity
return enemyHRP.Position + (velocity * Settings.predictionFactor)
end
-- Direction: Get Hit Direction Based on Attacker Position
local function getHitDirection(attackerPosition, playerPosition, camLookVector, camRightVector)
local direction = (attackerPosition - playerPosition).Unit
local dotProduct = direction:Dot(camLookVector)
if Settings.aimLockEnabled then
if dotProduct > math.cos(math.rad(45)) then
return BLOCK_DIRECTIONS.Forward
elseif dotProduct < -math.cos(math.rad(45)) then
return BLOCK_DIRECTIONS.Backward
else
return direction:Dot(camRightVector) > 0 and BLOCK_DIRECTIONS.Right or BLOCK_DIRECTIONS.Left
end
else
local angle = math.deg(math.atan2(direction.Z, direction.X)) % 360
if angle < 45 or angle >= 315 then
return BLOCK_DIRECTIONS.Forward
elseif angle < 135 then
return BLOCK_DIRECTIONS.Right
elseif angle < 225 then
return BLOCK_DIRECTIONS.Backward
else
return BLOCK_DIRECTIONS.Left
end
end
end
-- Direction: Update Block Direction
local function updateBlockDirection(attackerPosition)
local playerCharacter = LOCAL_PLAYER.Character
if not playerCharacter then return BLOCK_DIRECTIONS.Forward end
local playerHRP = playerCharacter:FindFirstChild("HumanoidRootPart")
if not playerHRP then return BLOCK_DIRECTIONS.Forward end
local playerPosition = playerHRP.Position
local camCFrame = CAMERA.CFrame
local camLookVector = camCFrame.LookVector
local camRightVector = camCFrame.RightVector
local desiredDirection = getHitDirection(attackerPosition, playerPosition, camLookVector, camRightVector)
if desiredDirection ~= State.currentBlockDirection then
State.currentBlockDirection = desiredDirection
UpdateBlockDirectionRemote:FireServer(desiredDirection)
debugPrint(string.format("Block direction updated to %s", desiredDirection))
-- Update Direction Indicator
local directionIcons = {
[BLOCK_DIRECTIONS.Forward] = "rbxassetid://4542562196", -- Forward Arrow Icon
[BLOCK_DIRECTIONS.Right] = "rbxassetid://4542562200", -- Right Arrow Icon (Replace with actual icon ID)
[BLOCK_DIRECTIONS.Backward] = "rbxassetid://4542562204", -- Backward Arrow Icon (Replace with actual icon ID)
[BLOCK_DIRECTIONS.Left] = "rbxassetid://4542562208" -- Left Arrow Icon (Replace with actual icon ID)
}
UI.DirectionIndicator:FindFirstChildOfClass("ImageLabel").Image = directionIcons[desiredDirection] or directionIcons[BLOCK_DIRECTIONS.Forward]
end
return desiredDirection
end
-- Counter Attacking: Perform Auto Counter
local function performAutoCounter(attacker)
local attackerId = attacker.UserId
local currentTime = tick()
if State.lastCounterTime[attackerId] and (currentTime - State.lastCounterTime[attackerId]) < Settings.counterCooldown then
return
end
-- Perform counter attack
VirtualInputManager:SendKeyEvent(true, Settings.counterKey, false, game)
task.delay(0.05, function()
VirtualInputManager:SendKeyEvent(false, Settings.counterKey, false, game)
end)
State.lastCounterTime[attackerId] = currentTime
debugPrint("Auto counter performed against " .. attacker.Name)
end
-- Counter Attacking: Perform Auto Counter for Slaps
local function counterSlap(attacker)
local attackerId = attacker.UserId
local currentTime = tick()
if State.lastCounterTime[attackerId] and (currentTime - State.lastCounterTime[attackerId]) < Settings.counterCooldown then
return
end
-- Perform counter slap attack
VirtualInputManager:SendKeyEvent(true, Settings.counterKey, false, game)
task.delay(0.05, function()
VirtualInputManager:SendKeyEvent(false, Settings.counterKey, false, game)
end)
State.lastCounterTime[attackerId] = currentTime
debugPrint("Auto counter (Slap) performed against " .. attacker.Name)
end
-- Blocking: Handle Incoming Hit with Enhanced Proximity and Throttling
local function handleIncomingHit(attacker, attackerPosition, attackType)
local attackerId = attacker.UserId
local currentTime = tick()
-- Determine appropriate cooldown and distance based on attack type
local cooldown = Settings.attackBlockCooldowns[attackType] or Settings.blockCooldown
local maxDistance = Settings.blockDistances[attackType] or Settings.blockDistances.Default
-- Check for general cooldown
if State.lastBlockTime[attackerId] and (currentTime - State.lastBlockTime[attackerId]) < cooldown then
return
end
-- Check distance
local playerCharacter = LOCAL_PLAYER.Character
if not playerCharacter then return end
local playerHRP = playerCharacter:FindFirstChild("HumanoidRootPart") -- Cached access
if not playerHRP then return end
local distance = (playerHRP.Position - attackerPosition).Magnitude
if distance > maxDistance then
return
end
-- Determine if the attack is a slap for specific handling
local isSlap = (attackType == "Slap")
if isSlap then
-- Handle Slap Blocking with Per-Attacker Cooldown
local slapCooldown = Settings.slap.slapCooldown
if not State.canSlap[attackerId] then
debugPrint("Slap blocked recently from " .. attacker.Name .. ". Ignoring to prevent spam.")
return
end
-- Update slap block state
State.canSlap[attackerId] = false
State.lastSlapBlockTime[attackerId] = currentTime
-- Display Slap Cooldown Timer if ESP is enabled
if Settings.slap.slapTimerESPEnabled and UI.SlapTimer then
UI.SlapTimer.Visible = true
UI.SlapTimer.Text = string.format("Slap Cooldown: %.1fs", slapCooldown)
-- Update the timer visually
task.spawn(function()
local startTime = tick()
while tick() - startTime < slapCooldown and Settings.slap.slapTimerESPEnabled and UI.SlapTimer.Visible do
local timeLeft = math.max(0, slapCooldown - (tick() - startTime))
UI.SlapTimer.Text = string.format("Slap Cooldown: %.1fs", timeLeft)
task.wait(0.1)
end
UI.SlapTimer.Visible = false
end)
end
end
-- Update last block time for throttling
State.lastBlockTime[attackerId] = currentTime
-- Determine reaction delay based on attack type
local reactionDelay = isSlap and Settings.slap.slapLagCompensation or Settings.reactionTimeThreshold
task.delay(reactionDelay, function()
local desiredDirection = updateBlockDirection(attackerPosition)
startBlocking()
-- Schedule unblocking with different delays based on attack type
local unblockDelay = isSlap and Settings.slap.slapLagCompensation or 0.5
task.delay(unblockDelay, stopBlocking)
end)
-- Handle Auto Countering if enabled and within counter distance
if Settings.autoCounterEnabled and distance <= Settings.autoCounterDistance then
if isSlap and Settings.slap.autoSlapEnabled and distance <= Settings.slap.autoSlapDistance then
counterSlap(attacker)
elseif not isSlap then
performAutoCounter(attacker)
end
end
-- Reset canSlap after cooldown if it's a slap
if isSlap then
task.spawn(function()
task.wait(Settings.slap.slapCooldown)
State.canSlap[attackerId] = true
debugPrint("Slap cooldown ended for " .. attacker.Name)
end)
end
end
-- Slap Blocking: Handle Slap Animation
local function handleSlapAnimation(player, animTrack)
if not Settings.slap.autoSlapEnabled then return end
local localCharacter = LOCAL_PLAYER.Character
local enemyCharacter = player.Character
if not localCharacter or not enemyCharacter then return end
local localHRP = localCharacter:FindFirstChild("HumanoidRootPart")
local enemyHRP = enemyCharacter:FindFirstChild("HumanoidRootPart")
if not localHRP or not enemyHRP then return end
local distance = (localHRP.Position - enemyHRP.Position).Magnitude
if distance <= Settings.blockDistances.Slap then
handleIncomingHit(player, enemyHRP.Position, "Slap")
end
end
-- Attack Detection: Handle Animation Played
local function onAnimationPlayed(animTrack, opponentPlayer)
local anim = animTrack.Animation
if not anim then return end
local animId = anim.AnimationId
if not animId then return end
-- Extract numeric ID from AnimationId
local numericAnimId = animId:match("rbxassetid://(%d+)")
if not numericAnimId then return end
numericAnimId = tonumber(numericAnimId)
if not numericAnimId then return end
local attackType = attackTypesInverse[tostring(numericAnimId)]
if not attackType then return end
debugPrint(string.format("Detected attack '%s' from %s", attackType, opponentPlayer.Name))
-- Handle Slap Animation Separately
if attackType == "Slap" then
handleSlapAnimation(opponentPlayer, animTrack)
else
local attackerCharacter = opponentPlayer.Character
if not attackerCharacter then return end
local attackerHRP = attackerCharacter:FindFirstChild("HumanoidRootPart")
if not attackerHRP then return end
handleIncomingHit(opponentPlayer, attackerHRP.Position, attackType)
end
end
-- Animation Monitoring: Connect Animation Events
local function monitorAnimations(character, opponentPlayer)
local humanoid = character:FindFirstChildOfClass("Humanoid")
if not humanoid then return end
local connection
connection = humanoid.AnimationPlayed:Connect(function(animTrack)
onAnimationPlayed(animTrack, opponentPlayer)
end)
-- Cleanup when character is removed
character.AncestryChanged:Connect(function(_, parent)
if not parent and connection then
connection:Disconnect()
end
end)
end
-- Hitbox Detection: Handle Hitbox Touched
local function onHitboxTouched(part, attackerPlayer)
if not part or attackerPlayer == LOCAL_PLAYER then return end
local attackerCharacter = part.Parent
if not attackerCharacter then return end
local attackerHRP = attackerCharacter:FindFirstChild("HumanoidRootPart")
if attackerHRP then
debugPrint("Hitbox detected attack from " .. attackerPlayer.Name)
handleIncomingHit(attackerPlayer, attackerHRP.Position, "Default") -- Assuming 'Default' for non-slap attacks
end
end
-- Hitbox Monitoring: Connect Hitbox Events
local function monitorHitboxes(character, attackerPlayer)
local hitboxes = CollectionService:GetTagged(ATTACK_HITBOX_TAG)
for _, hitbox in ipairs(hitboxes) do
if hitbox:IsDescendantOf(character) then
local connection
connection = hitbox.Touched:Connect(function(hitPart)
onHitboxTouched(hitPart, attackerPlayer)
end)
-- Cleanup when hitbox is removed
hitbox.AncestryChanged:Connect(function(_, parent)
if not parent and connection then
connection:Disconnect()
end
end)
-- Remove hitbox after specified time to prevent memory leaks
Debris:AddItem(hitbox, Settings.debrisLifetime)
end
end
end
-- Advanced Reaction System: Continuous Monitoring with Throttling
local function advancedReactionAutoBlock()
if not Settings.autoBlockEnabled then return end
local heartbeatThrottle = 0.05 -- Run logic every 0.05 seconds (20 times per second)
local accumulatedTime = 0
RunService.Heartbeat:Connect(function(deltaTime)
accumulatedTime += deltaTime
if accumulatedTime < heartbeatThrottle then
return
end
accumulatedTime = accumulatedTime - heartbeatThrottle
if not Settings.autoBlockEnabled then return end
local playerCharacter = LOCAL_PLAYER.Character
if not playerCharacter then return end
local playerHRP = playerCharacter:FindFirstChild("HumanoidRootPart")
if not playerHRP then return end
local playerPosition = playerHRP.Position
local camCFrame = CAMERA.CFrame
local camLookVector = camCFrame.LookVector
local camRightVector = camCFrame.RightVector
for _, plr in ipairs(Players:GetPlayers()) do
if plr == LOCAL_PLAYER or not plr.Character then continue end
local enemyCharacter = plr.Character
local enemyHRP = enemyCharacter:FindFirstChild("HumanoidRootPart")
if not enemyHRP then continue end
local distance = (playerPosition - enemyHRP.Position).Magnitude
-- Determine maximum relevant distance for this enemy based on attack types
local maxRelevantDistance = Settings.blockDistances.Default
for _, attackType in pairs(Settings.attackTypes) do
local attackDistance = Settings.blockDistances[attackType] or Settings.blockDistances.Default
if attackDistance > maxRelevantDistance then
maxRelevantDistance = attackDistance
end
end
if distance > maxRelevantDistance then continue end
-- Prediction and Direction Update
local predictedPosition = predictEnemyMovement(plr) or enemyHRP.Position
updateBlockDirection(predictedPosition)
local enemyHumanoid = enemyCharacter:FindFirstChildOfClass("Humanoid")
if not enemyHumanoid then continue end
-- Check for active attack animations
for _, animTrack in ipairs(enemyHumanoid:GetPlayingAnimationTracks()) do
local anim = animTrack.Animation
if not anim then continue end
local animId = anim.AnimationId
if not animId then continue end
local numericAnimId = animId:match("rbxassetid://(%d+)")
if not numericAnimId then continue end
numericAnimId = tonumber(numericAnimId)
if not numericAnimId then continue end
local attackType = attackTypesInverse[tostring(numericAnimId)]
if not attackType then continue end
-- Determine if the attack should be considered based on distance
local requiredDistance = Settings.blockDistances[attackType] or Settings.blockDistances.Default
if distance > requiredDistance then continue end
-- Handle Slap Animation Separately
if attackType == "Slap" then
handleSlapAnimation(plr, animTrack)
else
handleIncomingHit(plr, enemyHRP.Position, attackType)
end
end
end
end)
end
-- Player Monitoring: Handle New Players
local function onPlayerAdded(plr)
if plr == LOCAL_PLAYER then return end
local function onCharacterAdded(character)
monitorAnimations(character, plr)
monitorHitboxes(character, plr)
connectCharacterEvents(character)
end
plr.CharacterAdded:Connect(onCharacterAdded)
-- Handle existing character
if plr.Character then
onCharacterAdded(plr.Character)
end
end
-- Initialize Player Monitoring
local function initializePlayerMonitoring()
for _, plr in ipairs(Players:GetPlayers()) do
onPlayerAdded(plr)
end
Players.PlayerAdded:Connect(onPlayerAdded)
end
-- UI Feedback & Directional Block Update
local function updateUIAndDirection()
-- Update UI based on blocking state
local isBlocking = State.isBlocking
UI.LoadingBar.Size = isBlocking and UDim2.new(1, 0, 1, 0) or UDim2.new(0, 0, 1, 0)
UI.LoadingBar.BackgroundColor3 = isBlocking and Settings.ui.LoadingBar.BackgroundColorActive or Settings.ui.LoadingBar.BackgroundColorInactive
UI.MessageBox.Text = isBlocking and "Blocking Active" or (Settings.autoBlockEnabled and "Auto Block Enabled" or "Auto Block Disabled")
end
-- === Swing-Blocking Feature ===
-- Swing-Blocking: Perform Swing and Block
local function performSwingBlock()
if State.isBlocking then
debugPrint("Already blocking. Swing-block aborted.")
return
end
-- Start Blocking
startBlocking()
-- Simulate Mouse1 Click for Swing
VirtualInputManager:SendMouseButtonEvent(0, 0, Enum.UserInputType.MouseButton1, true, game, 1) -- MouseButton1 Down
task.delay(0.05, function()
VirtualInputManager:SendMouseButtonEvent(0, 0, Enum.UserInputType.MouseButton1, false, game, 1) -- MouseButton1 Up
end)
debugPrint("Swing action simulated.")
-- Maintain Blocking State for 0.7 seconds
task.delay(0.7, function()
stopBlocking()
end)
end
-- Input Handling: Manual Blocking and Swing
local function setupInputHandling()
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.Q then
toggleBlocking()
elseif input.KeyCode == Enum.KeyCode.R then
performSwingBlock()
end
end)
end
-- Character Cleanup: Handle Character Death or Removal
local function onCharacterRemoved(character)
stopBlocking()
end
local function connectCharacterEvents(character)
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid.Died:Connect(onCharacterRemoved)
end
character.AncestryChanged:Connect(function(_, parent)
if not parent then
stopBlocking()
end
end)
end
local function setupLocalPlayerCharacterMonitoring()
local function onLocalCharacterAdded(character)
connectCharacterEvents(character)
end
if LOCAL_PLAYER.Character then
connectCharacterEvents(LOCAL_PLAYER.Character)
end
LOCAL_PLAYER.CharacterAdded:Connect(onLocalCharacterAdded)
end
-- === Initialization ===
-- Setup UI
setupUI()
-- Setup Input Handling
setupInputHandling()
-- Initialize Player Monitoring
initializePlayerMonitoring()
-- Setup Local Player Character Monitoring
setupLocalPlayerCharacterMonitoring()
-- Setup Combined UI Feedback and Directional Block Update
RunService.RenderStepped:Connect(updateUIAndDirection)
-- Initialize Advanced Reaction System
advancedReactionAutoBlock()
-- Notify that the script is running
debugPrint("Autoblock V.3 is now running.")
``
Certainly! Enhancing your Autoblock V.3 script can significantly improve its functionality, user experience, and adaptability. Below are several advanced features you can incorporate into your script, along with detailed explanations and the updated code.
Configuration Persistence:
DataStoreService to save user settings.Customizable Key Bindings:
Player Blacklist/Whitelist:
Enhanced Prediction Algorithm:
Advanced UI Features:
Visual Notifications:
Notification GUIs or in-game text labels to display messages.Attack-Type Specific Blocking Strategies:
Below is the updated script incorporating the above enhancements. The additions are marked with comments for clarity.
autoBlockEnabled, customKeyBindings, blacklist, and whitelist.saveSettings and loadSettings functions handle the persistence of settings using the DataStore.customKeyBindings within the State table to store user-defined key bindings.F1 by default) to toggle the visibility of the settings panel.State.blacklist and State.whitelist store player names to ignore or exclusively block."TargetPlayerName"). For a complete solution, you'd implement input fields to accept player names dynamically.predictionFactor to 0.7 for better anticipation of enemy movements.blockDistances and attackBlockCooldowns to accommodate more attack types with individualized settings.By integrating these enhancements, Autoblock V.4 becomes a more robust, user-friendly, and versatile tool, offering players greater control and customization over their in-game blocking and countering behaviors.
Not yet included in a published release.
--[[
Autoblock V.4
Super Advanced Auto Block & Swing Script for Saber Showdown
Enhanced with configuration persistence, customizable key bindings, player blacklist/whitelist,
improved prediction algorithm, advanced UI features, visual notifications, and attack-type specific strategies.
Author: Keperman209
Version: 4.0
Date: 10.03.2024
--]]
-- === Services ===
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local VirtualInputManager = game:GetService("VirtualInputManager")
local CollectionService = game:GetService("CollectionService")
local Debris = game:GetService("Debris")
local Workspace = workspace
local DataStoreService = game:GetService("DataStoreService")
local TweenService = game:GetService("TweenService")
-- === Constants ===
local LOCAL_PLAYER = Players.LocalPlayer
local CAMERA = Workspace.CurrentCamera
local ATTACK_HITBOX_TAG = "AttackHitbox"
local BLOCK_DIRECTIONS = {
Forward = 1,
Right = 2,
Backward = 3,
Left = 4
}
-- === Remotes ===
local LightsaberRemotes = ReplicatedStorage:WaitForChild("LightsaberRemotes")
local BlockRemote = LightsaberRemotes:WaitForChild("Block")
local UnblockRemote = LightsaberRemotes:WaitForChild("Unblock")
local UpdateBlockDirectionRemote = LightsaberRemotes:WaitForChild("UpdateBlockDirection")
-- === DataStore Initialization ===
local SettingsStore = DataStoreService:GetDataStore("AutoblockV4_Settings")
-- === Settings ===
local Settings = {
-- Blocking Settings
blockDistances = { -- Max distance to attempt a block per attack type
Slap = 10, -- Slaps require closer proximity
Default = 15, -- Default distance for other attacks
Punch = 12, -- Example attack distance
Kick = 14 -- Example attack distance
},
autoBlockEnabled = true, -- Enable/Disable dynamic auto-blocking
blockCooldown = 0.5, -- General cooldown between blocks (seconds)
attackBlockCooldowns = { -- Cooldown between blocks per attack type (seconds)
Slap = 0.2,
Punch = 0.3,
Kick = 0.4,
Default = 0.5
},
attackTypes = { -- Attack animation IDs
Slap = 12625891544,
SlappedLegs = 12671715182,
SlappedArms = 12625896358,
Punch = 12625897000, -- Example attack ID
Kick = 12625897500, -- Example attack ID
KickUp = 12625897944, -- Added KickUp
KickBack = 12625899752 -- Added KickBack
},
-- Counter Attacking Settings
autoCounterEnabled = true, -- Enable/Disable auto counter attacks
autoCounterDistance = 10, -- Distance within which to auto counter
counterCooldown = 1.5, -- Cooldown between counters (seconds)
counterKey = Enum.KeyCode.E, -- Default key to use for countering
-- Reaction Settings
reactionTimeThreshold = 0.2, -- Threshold for reaction time (in seconds)
predictionFactor = 0.7, -- Increased factor for better prediction
-- Slap Lag Handling
slapLagCompensation = 0.3, -- Increased delay to compensate for lag in slap attacks
-- Aim-Lock Directional Block Settings
aimLockEnabled = true, -- Enable/Disable aim-lock directional blocking
aimLockSmoothness = 0.1, -- Smoothness factor for direction adjustment
-- Slap Blocking Specific Settings
slap = {
slapCooldown = 1.0, -- Cooldown between handling slap blocks (seconds)
autoSlapEnabled = true, -- Enable/Disable auto countering slaps
autoSlapDistance = 8, -- Distance within which to auto counter slaps
slapTimerESPEnabled = true, -- Enable/Disable visual cooldown indicator for slaps
},
-- Blacklist/Whitelist Settings
blacklist = {}, -- Players to ignore
whitelist = {}, -- Players to exclusively block
-- UI Settings
ui = {
ScreenGuiName = "AutoBlockUI_V4", -- Updated UI name
-- Black Box Frame
BlackBox = {
Size = UDim2.new(0.3, 0, 0.25, 0),
Position = UDim2.new(0.35, 0, 0.75, 0),
BackgroundColor = Color3.fromRGB(30, 30, 30),
BackgroundTransparency = 0.15,
CornerRadius = 12,
BorderColor = Color3.fromRGB(255, 255, 255),
BorderSizePixel = 2
},
-- Loading Bar
LoadingBar = {
Size = UDim2.new(1, -20, 0.25, -10),
Position = UDim2.new(0, 10, 0.1, 10),
BackgroundColorActive = Color3.fromRGB(0, 255, 0),
BackgroundColorInactive = Color3.fromRGB(255, 0, 0),
BackgroundTransparency = 0.3,
CornerRadius = 8
},
-- Message Box
MessageBox = {
Size = UDim2.new(1, -20, 0.4, -10),
Position = UDim2.new(0, 10, 0.35, 10),
BackgroundTransparency = 1,
TextColor = Color3.fromRGB(255, 255, 255),
TextScaled = true,
Font = Enum.Font.GothamSemibold,
Text = "Press 'Q' to toggle Auto Block",
TextStrokeColor = Color3.fromRGB(0, 0, 0),
TextStrokeTransparency = 0.5
},
-- Direction Indicator
DirectionIndicator = {
Size = UDim2.new(0.2, -10, 0.5, -10),
Position = UDim2.new(0.4, 10, 0.5, 10),
BackgroundColor = Color3.fromRGB(50, 50, 50),
BackgroundTransparency = 0.3,
CornerRadius = 8,
Image = nil -- Placeholder for directional icons
},
-- Toggle Button
ToggleButton = {
Size = UDim2.new(0.3, -20, 0.25, -10),
Position = UDim2.new(0.35, 10, 0.7, 10),
BackgroundColor = Color3.fromRGB(70, 130, 180),
BackgroundTransparency = 0.3,
CornerRadius = 8,
TextColor = Color3.fromRGB(255, 255, 255),
TextScaled = true,
Font = Enum.Font.GothamBold,
Text = "Disable Auto Block",
TextStrokeColor = Color3.fromRGB(0, 0, 0),
TextStrokeTransparency = 0.5
},
-- Slap Timer (ESP) Visual Indicator
SlapTimer = {
Size = UDim2.new(0.3, -20, 0.05, -10),
Position = UDim2.new(0.35, 10, 0.8, 10),
BackgroundColor = Color3.fromRGB(255, 0, 0),
BackgroundTransparency = 0.3,
CornerRadius = 8,
Visible = false,
TextColor = Color3.fromRGB(255, 255, 255),
TextScaled = true,
Font = Enum.Font.GothamSemibold,
Text = "Slap Cooldown: 0s",
TextStrokeColor = Color3.fromRGB(0, 0, 0),
TextStrokeTransparency = 0.5
},
-- Settings Panel
SettingsPanel = {
Size = UDim2.new(0.4, 0, 0.6, 0),
Position = UDim2.new(0.3, 0, 0.2, 0),
BackgroundColor = Color3.fromRGB(40, 40, 40),
BackgroundTransparency = 0.2,
CornerRadius = 16,
BorderColor = Color3.fromRGB(255, 255, 255),
BorderSizePixel = 2,
Visible = false
},
-- Save Button
SaveButton = {
Size = UDim2.new(0.3, -20, 0.05, -10),
Position = UDim2.new(0.35, 10, 0.9, 10),
BackgroundColor = Color3.fromRGB(34, 139, 34),
BackgroundTransparency = 0.3,
CornerRadius = 8,
TextColor = Color3.fromRGB(255, 255, 255),
TextScaled = true,
Font = Enum.Font.GothamBold,
Text = "Save Settings",
TextStrokeColor = Color3.fromRGB(0, 0, 0),
TextStrokeTransparency = 0.5
},
-- Load Button
LoadButton = {
Size = UDim2.new(0.3, -20, 0.05, -10),
Position = UDim2.new(0.65, 10, 0.9, 10),
BackgroundColor = Color3.fromRGB(178, 34, 34),
BackgroundTransparency = 0.3,
CornerRadius = 8,
TextColor = Color3.fromRGB(255, 255, 255),
TextScaled = true,
Font = Enum.Font.GothamBold,
Text = "Load Settings",
TextStrokeColor = Color3.fromRGB(0, 0, 0),
TextStrokeTransparency = 0.5
},
-- Notification Text
Notification = {
Size = UDim2.new(0.3, -20, 0.05, -10),
Position = UDim2.new(0.35, 10, 0.05, 10),
BackgroundColor = Color3.fromRGB(0, 0, 0),
BackgroundTransparency = 0.5,
CornerRadius = 8,
Visible = false,
TextColor = Color3.fromRGB(255, 255, 255),
TextScaled = true,
Font = Enum.Font.GothamSemibold,
Text = "Notification",
TextStrokeColor = Color3.fromRGB(0, 0, 0),
TextStrokeTransparency = 0.5
}
},
-- Debris Settings
debrisLifetime = 300, -- Time in seconds before debris is removed (e.g., hitboxes)
}
-- === Inverse Mapping for Attack Types ===
local attackTypesInverse = {}
for attack, id in pairs(Settings.attackTypes) do
attackTypesInverse[tostring(id)] = attack
end
-- === State Tracking ===
local State = {
isBlocking = false,
lastBlockTime = {}, -- [player.UserId] = timestamp
lastCounterTime = {}, -- [player.UserId] = timestamp
currentBlockDirection = BLOCK_DIRECTIONS.Forward,
autoBlockEnabled = Settings.autoBlockEnabled,
lastSlapBlockTime = {}, -- [player.UserId] = timestamp
canSlap = {}, -- [player.UserId] = boolean indicating if player can slap
customKeyBindings = { -- Customizable key bindings
ToggleBlock = Enum.KeyCode.Q,
SwingBlock = Enum.KeyCode.R,
OpenSettings = Enum.KeyCode.F1
},
blacklist = Settings.blacklist, -- Blacklist initialized from Settings
whitelist = Settings.whitelist -- Whitelist initialized from Settings
}
-- === UI Elements ===
local UI = {
ScreenGui = nil,
BlackBox = nil,
LoadingBar = nil,
MessageBox = nil,
DirectionIndicator = nil,
ToggleButton = nil,
SlapTimer = nil,
SettingsPanel = nil,
SaveButton = nil,
LoadButton = nil,
Notification = nil
}
-- === Helper Functions ===
-- Utility: Print with timestamp
local function debugPrint(message)
print(string.format("[%s] %s", os.date("%H:%M:%S"), message))
end
-- UI: Create Rounded Corners for Frames
local function addRoundedCorners(frame, radius)
local corner = Instance.new("UICorner")
corner.CornerRadius = UDim.new(0, radius)
corner.Parent = frame
return corner
end
-- UI: Display Notifications
local function showNotification(text, duration)
UI.Notification.Text = text
UI.Notification.Visible = true
-- Tweening for fade in and out
local fadeIn = TweenService:Create(UI.Notification, TweenInfo.new(0.5), {BackgroundTransparency = 0.2})
local fadeOut = TweenService:Create(UI.Notification, TweenInfo.new(0.5), {BackgroundTransparency = 0.5})
fadeIn:Play()
task.delay(duration, function()
fadeOut:Play()
task.delay(0.5, function()
UI.Notification.Visible = false
end)
end)
end
-- DataStore: Save Settings
local function saveSettings()
local success, errorMessage = pcall(function()
SettingsStore:SetAsync(tostring(LOCAL_PLAYER.UserId), {
autoBlockEnabled = State.autoBlockEnabled,
customKeyBindings = State.customKeyBindings,
blacklist = State.blacklist,
whitelist = State.whitelist
})
end)
if success then
showNotification("Settings saved successfully!", 2)
debugPrint("Settings saved.")
else
showNotification("Failed to save settings: " .. errorMessage, 2)
debugPrint("Error saving settings: " .. errorMessage)
end
end
-- DataStore: Load Settings
local function loadSettings()
local success, data = pcall(function()
return SettingsStore:GetAsync(tostring(LOCAL_PLAYER.UserId))
end)
if success and data then
State.autoBlockEnabled = data.autoBlockEnabled
State.customKeyBindings = data.customKeyBindings or State.customKeyBindings
State.blacklist = data.blacklist or {}
State.whitelist = data.whitelist or {}
showNotification("Settings loaded successfully!", 2)
debugPrint("Settings loaded.")
-- Update UI elements to reflect loaded settings
UI.ToggleButton.Text = State.autoBlockEnabled and "Disable Auto Block" or "Enable Auto Block"
UI.ToggleButton.BackgroundColor3 = State.autoBlockEnabled and Settings.ui.ToggleButton.BackgroundColor or Color3.fromRGB(169, 169, 169)
else
showNotification("Failed to load settings: " .. (data or "No Data"), 2)
debugPrint("Error loading settings: " .. (data or "No Data"))
end
end
-- UI: Setup the User Interface
local function setupUI()
local screenGui = Instance.new("ScreenGui")
screenGui.Name = Settings.ui.ScreenGuiName
screenGui.Parent = LOCAL_PLAYER:WaitForChild("PlayerGui")
screenGui.ResetOnSpawn = false
screenGui.DisplayOrder = 1000 -- Ensure it's on top
-- Black Box Frame
local blackBox = Instance.new("Frame")
blackBox.Size = Settings.ui.BlackBox.Size
blackBox.Position = Settings.ui.BlackBox.Position
blackBox.BackgroundColor3 = Settings.ui.BlackBox.BackgroundColor
blackBox.BackgroundTransparency = Settings.ui.BlackBox.BackgroundTransparency
blackBox.BorderSizePixel = Settings.ui.BlackBox.BorderSizePixel
blackBox.BorderColor3 = Settings.ui.BlackBox.BorderColor
blackBox.Parent = screenGui
addRoundedCorners(blackBox, Settings.ui.BlackBox.CornerRadius)
-- Loading Bar Background
local loadingBarBackground = Instance.new("Frame")
loadingBarBackground.Size = Settings.ui.LoadingBar.Size
loadingBarBackground.Position = Settings.ui.LoadingBar.Position
loadingBarBackground.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
loadingBarBackground.BackgroundTransparency = 0.3
loadingBarBackground.BorderSizePixel = 0
loadingBarBackground.Parent = blackBox
addRoundedCorners(loadingBarBackground, Settings.ui.LoadingBar.CornerRadius or 8)
-- Loading Bar Foreground
local loadingBar = Instance.new("Frame")
loadingBar.Size = UDim2.new(0, 0, 1, 0) -- Start empty
loadingBar.Position = UDim2.new(0, 0, 0, 0)
loadingBar.BackgroundColor3 = Settings.ui.LoadingBar.BackgroundColorInactive
loadingBar.BorderSizePixel = 0
loadingBar.Parent = loadingBarBackground
addRoundedCorners(loadingBar, Settings.ui.LoadingBar.CornerRadius or 8)
-- Message Box
local messageBox = Instance.new("TextLabel")
messageBox.Size = Settings.ui.MessageBox.Size
messageBox.Position = Settings.ui.MessageBox.Position
messageBox.BackgroundTransparency = Settings.ui.MessageBox.BackgroundTransparency
messageBox.TextColor3 = Settings.ui.MessageBox.TextColor
messageBox.TextScaled = Settings.ui.MessageBox.TextScaled
messageBox.Text = Settings.ui.MessageBox.Text
messageBox.Font = Settings.ui.MessageBox.Font
messageBox.TextStrokeColor3 = Settings.ui.MessageBox.TextStrokeColor
messageBox.TextStrokeTransparency = Settings.ui.MessageBox.TextStrokeTransparency
messageBox.BorderSizePixel = 0
messageBox.Parent = blackBox
-- Direction Indicator
local directionIndicator = Instance.new("Frame")
directionIndicator.Size = Settings.ui.DirectionIndicator.Size
directionIndicator.Position = Settings.ui.DirectionIndicator.Position
directionIndicator.BackgroundColor3 = Settings.ui.DirectionIndicator.BackgroundColor
directionIndicator.BackgroundTransparency = Settings.ui.DirectionIndicator.BackgroundTransparency
directionIndicator.BorderSizePixel = 0
directionIndicator.Parent = blackBox
addRoundedCorners(directionIndicator, Settings.ui.DirectionIndicator.CornerRadius or 8)
-- Direction Indicator Icon
local directionIcon = Instance.new("ImageLabel")
directionIcon.Size = UDim2.new(0.8, 0, 0.8, 0)
directionIcon.Position = UDim2.new(0.1, 0, 0.1, 0)
directionIcon.BackgroundTransparency = 1
directionIcon.Image = "rbxassetid://4542562196" -- Placeholder: Forward Arrow Icon
directionIcon.Visible = true
directionIcon.Parent = directionIndicator
-- Toggle Button
local toggleButton = Instance.new("TextButton")
toggleButton.Size = Settings.ui.ToggleButton.Size
toggleButton.Position = Settings.ui.ToggleButton.Position
toggleButton.BackgroundColor3 = Settings.ui.ToggleButton.BackgroundColor
toggleButton.BackgroundTransparency = Settings.ui.ToggleButton.BackgroundTransparency
toggleButton.BorderSizePixel = 0
toggleButton.TextColor3 = Settings.ui.ToggleButton.TextColor
toggleButton.TextScaled = Settings.ui.ToggleButton.TextScaled
toggleButton.Font = Settings.ui.ToggleButton.Font
toggleButton.Text = Settings.ui.ToggleButton.Text
toggleButton.TextStrokeColor3 = Settings.ui.ToggleButton.TextStrokeColor
toggleButton.TextStrokeTransparency = Settings.ui.ToggleButton.TextStrokeTransparency
toggleButton.Parent = blackBox
addRoundedCorners(toggleButton, Settings.ui.ToggleButton.CornerRadius or 8)
-- Toggle Button Hover Effect
toggleButton.MouseEnter:Connect(function()
toggleButton.BackgroundColor3 = Color3.fromRGB(100, 149, 237)
end)
toggleButton.MouseLeave:Connect(function()
toggleButton.BackgroundColor3 = State.autoBlockEnabled and Settings.ui.ToggleButton.BackgroundColor or Color3.fromRGB(169, 169, 169)
end)
-- Toggle Button Functionality
toggleButton.MouseButton1Click:Connect(function()
State.autoBlockEnabled = not State.autoBlockEnabled
toggleButton.Text = State.autoBlockEnabled and "Disable Auto Block" or "Enable Auto Block"
toggleButton.BackgroundColor3 = State.autoBlockEnabled and Settings.ui.ToggleButton.BackgroundColor or Color3.fromRGB(169, 169, 169)
UI.MessageBox.Text = State.autoBlockEnabled and "Auto Block Enabled" or "Auto Block Disabled"
debugPrint("Auto Block " .. (State.autoBlockEnabled and "Enabled" or "Disabled"))
showNotification("Auto Block " .. (State.autoBlockEnabled and "Enabled" or "Disabled"), 2)
end)
-- Slap Timer (ESP) Visual Indicator
local slapTimer = Instance.new("TextLabel")
slapTimer.Size = Settings.ui.SlapTimer.Size
slapTimer.Position = Settings.ui.SlapTimer.Position
slapTimer.BackgroundColor3 = Settings.ui.SlapTimer.BackgroundColor
slapTimer.BackgroundTransparency = Settings.ui.SlapTimer.BackgroundTransparency
slapTimer.BorderSizePixel = 0
slapTimer.TextColor3 = Settings.ui.SlapTimer.TextColor
slapTimer.TextScaled = Settings.ui.SlapTimer.TextScaled
slapTimer.Font = Settings.ui.SlapTimer.Font
slapTimer.Text = Settings.ui.SlapTimer.Text
slapTimer.TextStrokeColor3 = Settings.ui.SlapTimer.TextStrokeColor
slapTimer.TextStrokeTransparency = Settings.ui.SlapTimer.TextStrokeTransparency
slapTimer.Visible = Settings.ui.SlapTimer.Visible
slapTimer.Parent = blackBox
addRoundedCorners(slapTimer, Settings.ui.SlapTimer.CornerRadius or 8)
-- Settings Panel
local settingsPanel = Instance.new("Frame")
settingsPanel.Size = Settings.ui.SettingsPanel.Size
settingsPanel.Position = Settings.ui.SettingsPanel.Position
settingsPanel.BackgroundColor3 = Settings.ui.SettingsPanel.BackgroundColor
settingsPanel.BackgroundTransparency = Settings.ui.SettingsPanel.BackgroundTransparency
settingsPanel.BorderSizePixel = Settings.ui.SettingsPanel.BorderSizePixel
settingsPanel.BorderColor3 = Settings.ui.SettingsPanel.BorderColor
settingsPanel.Visible = Settings.ui.SettingsPanel.Visible
settingsPanel.Parent = screenGui
addRoundedCorners(settingsPanel, Settings.ui.SettingsPanel.CornerRadius)
-- Save Button
local saveButton = Instance.new("TextButton")
saveButton.Size = Settings.ui.SaveButton.Size
saveButton.Position = Settings.ui.SaveButton.Position
saveButton.BackgroundColor3 = Settings.ui.SaveButton.BackgroundColor
saveButton.BackgroundTransparency = Settings.ui.SaveButton.BackgroundTransparency
saveButton.BorderSizePixel = 0
saveButton.TextColor3 = Settings.ui.SaveButton.TextColor
saveButton.TextScaled = Settings.ui.SaveButton.TextScaled
saveButton.Font = Settings.ui.SaveButton.Font
saveButton.Text = Settings.ui.SaveButton.Text
saveButton.TextStrokeColor3 = Settings.ui.SaveButton.TextStrokeColor
saveButton.TextStrokeTransparency = Settings.ui.SaveButton.TextStrokeTransparency
saveButton.Parent = settingsPanel
addRoundedCorners(saveButton, Settings.ui.SaveButton.CornerRadius or 8)
-- Save Button Functionality
saveButton.MouseButton1Click:Connect(function()
saveSettings()
end)
-- Load Button
local loadButton = Instance.new("TextButton")
loadButton.Size = Settings.ui.LoadButton.Size
loadButton.Position = Settings.ui.LoadButton.Position
loadButton.BackgroundColor3 = Settings.ui.LoadButton.BackgroundColor
loadButton.BackgroundTransparency = Settings.ui.LoadButton.BackgroundTransparency
loadButton.BorderSizePixel = 0
loadButton.TextColor3 = Settings.ui.LoadButton.TextColor
loadButton.TextScaled = Settings.ui.LoadButton.TextScaled
loadButton.Font = Settings.ui.LoadButton.Font
loadButton.Text = Settings.ui.LoadButton.Text
loadButton.TextStrokeColor3 = Settings.ui.LoadButton.TextStrokeColor
loadButton.TextStrokeTransparency = Settings.ui.LoadButton.TextStrokeTransparency
loadButton.Parent = settingsPanel
addRoundedCorners(loadButton, Settings.ui.LoadButton.CornerRadius or 8)
-- Load Button Functionality
loadButton.MouseButton1Click:Connect(function()
loadSettings()
end)
-- Notification Text
local notification = Instance.new("TextLabel")
notification.Size = Settings.ui.Notification.Size
notification.Position = Settings.ui.Notification.Position
notification.BackgroundColor3 = Settings.ui.Notification.BackgroundColor
notification.BackgroundTransparency = Settings.ui.Notification.BackgroundTransparency
notification.BorderSizePixel = 0
notification.TextColor3 = Settings.ui.Notification.TextColor
notification.TextScaled = Settings.ui.Notification.TextScaled
notification.Font = Settings.ui.Notification.Font
notification.Text = Settings.ui.Notification.Text
notification.TextStrokeColor3 = Settings.ui.Notification.TextStrokeColor
notification.TextStrokeTransparency = Settings.ui.Notification.TextStrokeTransparency
notification.Visible = Settings.ui.Notification.Visible
notification.Parent = screenGui
addRoundedCorners(notification, 8)
-- Assign UI Elements to the UI Table
UI.ScreenGui = screenGui
UI.BlackBox = blackBox
UI.LoadingBar = loadingBar
UI.MessageBox = messageBox
UI.DirectionIndicator = directionIndicator
UI.ToggleButton = toggleButton
UI.SlapTimer = slapTimer
UI.SettingsPanel = settingsPanel
UI.SaveButton = saveButton
UI.LoadButton = loadButton
UI.Notification = notification
end
-- Blocking: Start Blocking
local function startBlocking()
if not State.isBlocking then
State.isBlocking = true
BlockRemote:FireServer()
UI.MessageBox.Text = "Blocking Active"
UI.LoadingBar.BackgroundColor3 = Settings.ui.LoadingBar.BackgroundColorActive
UI.LoadingBar:TweenSize(UDim2.new(1, 0, 1, 0), "Out", "Quad", 0.2, true)
debugPrint("Blocking started")
showNotification("Blocking Started", 1.5)
end
end
-- Blocking: Stop Blocking
local function stopBlocking()
if State.isBlocking then
State.isBlocking = false
UnblockRemote:FireServer()
UI.MessageBox.Text = State.autoBlockEnabled and "Auto Block Enabled" or "Auto Block Disabled"
UI.LoadingBar.BackgroundColor3 = Settings.ui.LoadingBar.BackgroundColorInactive
UI.LoadingBar:TweenSize(UDim2.new(0, 0, 1, 0), "Out", "Quad", 0.2, true)
debugPrint("Blocking stopped")
showNotification("Blocking Stopped", 1.5)
end
end
-- Blocking: Toggle Blocking State
local function toggleBlocking()
if State.isBlocking then
stopBlocking()
else
startBlocking()
end
end
-- Prediction: Predict Enemy Movement with Enhanced Algorithm
local function predictEnemyMovement(enemy)
local enemyCharacter = enemy.Character
if not enemyCharacter then return nil end
local enemyHRP = enemyCharacter:FindFirstChild("HumanoidRootPart")
if not enemyHRP then return nil end
local velocity = enemyHRP.Velocity
-- Incorporate acceleration if possible (requires access to previous velocity)
-- For simplicity, we'll use velocity and prediction factor
return enemyHRP.Position + (velocity * Settings.predictionFactor)
end
-- Direction: Get Hit Direction Based on Attacker Position
local function getHitDirection(attackerPosition, playerPosition, camLookVector, camRightVector)
local direction = (attackerPosition - playerPosition).Unit
local dotProduct = direction:Dot(camLookVector)
if Settings.aimLockEnabled then
if dotProduct > math.cos(math.rad(45)) then
return BLOCK_DIRECTIONS.Forward
elseif dotProduct < -math.cos(math.rad(45)) then
return BLOCK_DIRECTIONS.Backward
else
return direction:Dot(camRightVector) > 0 and BLOCK_DIRECTIONS.Right or BLOCK_DIRECTIONS.Left
end
else
local angle = math.deg(math.atan2(direction.Z, direction.X)) % 360
if angle < 45 or angle >= 315 then
return BLOCK_DIRECTIONS.Forward
elseif angle < 135 then
return BLOCK_DIRECTIONS.Right
elseif angle < 225 then
return BLOCK_DIRECTIONS.Backward
else
return BLOCK_DIRECTIONS.Left
end
end
end
-- Direction: Update Block Direction
local function updateBlockDirection(attackerPosition)
local playerCharacter = LOCAL_PLAYER.Character
if not playerCharacter then return BLOCK_DIRECTIONS.Forward end
local playerHRP = playerCharacter:FindFirstChild("HumanoidRootPart")
if not playerHRP then return BLOCK_DIRECTIONS.Forward end
local playerPosition = playerHRP.Position
local camCFrame = CAMERA.CFrame
local camLookVector = camCFrame.LookVector
local camRightVector = camCFrame.RightVector
local desiredDirection = getHitDirection(attackerPosition, playerPosition, camLookVector, camRightVector)
if desiredDirection ~= State.currentBlockDirection then
State.currentBlockDirection = desiredDirection
UpdateBlockDirectionRemote:FireServer(desiredDirection)
debugPrint(string.format("Block direction updated to %s", desiredDirection))
-- Update Direction Indicator
local directionIcons = {
[BLOCK_DIRECTIONS.Forward] = "rbxassetid://4542562196", -- Forward Arrow Icon
[BLOCK_DIRECTIONS.Right] = "rbxassetid://4542562200", -- Right Arrow Icon (Replace with actual icon ID)
[BLOCK_DIRECTIONS.Backward] = "rbxassetid://4542562204", -- Backward Arrow Icon (Replace with actual icon ID)
[BLOCK_DIRECTIONS.Left] = "rbxassetid://4542562208" -- Left Arrow Icon (Replace with actual icon ID)
}
UI.DirectionIndicator:FindFirstChildOfClass("ImageLabel").Image = directionIcons[desiredDirection] or directionIcons[BLOCK_DIRECTIONS.Forward]
end
return desiredDirection
end
-- Counter Attacking: Perform Auto Counter
local function performAutoCounter(attacker)
local attackerId = attacker.UserId
local currentTime = tick()
if State.lastCounterTime[attackerId] and (currentTime - State.lastCounterTime[attackerId]) < Settings.counterCooldown then
return
end
-- Perform counter attack
VirtualInputManager:SendKeyEvent(true, State.customKeyBindings.CounterKey or Settings.counterKey, false, game)
task.delay(0.05, function()
VirtualInputManager:SendKeyEvent(false, State.customKeyBindings.CounterKey or Settings.counterKey, false, game)
end)
State.lastCounterTime[attackerId] = currentTime
debugPrint("Auto counter performed against " .. attacker.Name)
showNotification("Auto Counter Executed", 1.5)
end
-- Counter Attacking: Perform Auto Counter for Slaps
local function counterSlap(attacker)
local attackerId = attacker.UserId
local currentTime = tick()
if State.lastCounterTime[attackerId] and (currentTime - State.lastCounterTime[attackerId]) < Settings.counterCooldown then
return
end
-- Perform counter slap attack
VirtualInputManager:SendKeyEvent(true, State.customKeyBindings.CounterKey or Settings.counterKey, false, game)
task.delay(0.05, function()
VirtualInputManager:SendKeyEvent(false, State.customKeyBindings.CounterKey or Settings.counterKey, false, game)
end)
State.lastCounterTime[attackerId] = currentTime
debugPrint("Auto counter (Slap) performed against " .. attacker.Name)
showNotification("Auto Counter (Slap) Executed", 1.5)
end
-- Blocking: Handle Incoming Hit with Enhanced Proximity and Throttling
local function handleIncomingHit(attacker, attackerPosition, attackType)
local attackerId = attacker.UserId
local currentTime = tick()
-- Skip if attacker is blacklisted
if table.find(State.blacklist, attacker.Name) then
debugPrint("Attacker " .. attacker.Name .. " is blacklisted. Ignoring.")
return
end
-- If whitelist is active, only handle attackers in whitelist
if #State.whitelist > 0 and not table.find(State.whitelist, attacker.Name) then
debugPrint("Attacker " .. attacker.Name .. " is not in whitelist. Ignoring.")
return
end
-- Determine appropriate cooldown and distance based on attack type
local cooldown = Settings.attackBlockCooldowns[attackType] or Settings.blockCooldown
local maxDistance = Settings.blockDistances[attackType] or Settings.blockDistances.Default
-- Check for general cooldown
if State.lastBlockTime[attackerId] and (currentTime - State.lastBlockTime[attackerId]) < cooldown then
return
end
-- Check distance
local playerCharacter = LOCAL_PLAYER.Character
if not playerCharacter then return end
local playerHRP = playerCharacter:FindFirstChild("HumanoidRootPart") -- Cached access
if not playerHRP then return end
local distance = (playerHRP.Position - attackerPosition).Magnitude
if distance > maxDistance then
return
end
-- Determine if the attack is a slap for specific handling
local isSlap = (attackType == "Slap")
if isSlap then
-- Handle Slap Blocking with Per-Attacker Cooldown
local slapCooldown = Settings.slap.slapCooldown
if not State.canSlap[attackerId] then
debugPrint("Slap blocked recently from " .. attacker.Name .. ". Ignoring to prevent spam.")
return
end
-- Update slap block state
State.canSlap[attackerId] = false
State.lastSlapBlockTime[attackerId] = currentTime
-- Display Slap Cooldown Timer if ESP is enabled
if Settings.slap.slapTimerESPEnabled and UI.SlapTimer then
UI.SlapTimer.Visible = true
UI.SlapTimer.Text = string.format("Slap Cooldown: %.1fs", slapCooldown)
-- Update the timer visually
task.spawn(function()
local startTime = tick()
while tick() - startTime < slapCooldown and Settings.slap.slapTimerESPEnabled and UI.SlapTimer.Visible do
local timeLeft = math.max(0, slapCooldown - (tick() - startTime))
UI.SlapTimer.Text = string.format("Slap Cooldown: %.1fs", timeLeft)
task.wait(0.1)
end
UI.SlapTimer.Visible = false
end)
end
end
-- Update last block time for throttling
State.lastBlockTime[attackerId] = currentTime
-- Determine reaction delay based on attack type
local reactionDelay = isSlap and Settings.slap.slapLagCompensation or Settings.reactionTimeThreshold
task.delay(reactionDelay, function()
local desiredDirection = updateBlockDirection(attackerPosition)
startBlocking()
-- Schedule unblocking with different delays based on attack type
local unblockDelay = isSlap and Settings.slap.slapLagCompensation or 0.5
task.delay(unblockDelay, stopBlocking)
end)
-- Handle Auto Countering if enabled and within counter distance
if Settings.autoCounterEnabled and distance <= Settings.autoCounterDistance then
if isSlap and Settings.slap.autoSlapEnabled and distance <= Settings.slap.autoSlapDistance then
counterSlap(attacker)
elseif not isSlap then
performAutoCounter(attacker)
end
end
-- Reset canSlap after cooldown if it's a slap
if isSlap then
task.spawn(function()
task.wait(Settings.slap.slapCooldown)
State.canSlap[attackerId] = true
debugPrint("Slap cooldown ended for " .. attacker.Name)
end)
end
end
-- Slap Blocking: Handle Slap Animation
local function handleSlapAnimation(player, animTrack)
if not Settings.slap.autoSlapEnabled then return end
local localCharacter = LOCAL_PLAYER.Character
local enemyCharacter = player.Character
if not localCharacter or not enemyCharacter then return end
local localHRP = localCharacter:FindFirstChild("HumanoidRootPart")
local enemyHRP = enemyCharacter:FindFirstChild("HumanoidRootPart")
if not localHRP or not enemyHRP then return end
local distance = (localHRP.Position - enemyHRP.Position).Magnitude
if distance <= Settings.blockDistances.Slap then
handleIncomingHit(player, enemyHRP.Position, "Slap")
end
end
-- Attack Detection: Handle Animation Played
local function onAnimationPlayed(animTrack, opponentPlayer)
local anim = animTrack.Animation
if not anim then return end
local animId = anim.AnimationId
if not animId then return end
-- Extract numeric ID from AnimationId
local numericAnimId = animId:match("rbxassetid://(%d+)")
if not numericAnimId then return end
numericAnimId = tonumber(numericAnimId)
if not numericAnimId then return end
local attackType = attackTypesInverse[tostring(numericAnimId)]
if not attackType then return end
debugPrint(string.format("Detected attack '%s' from %s", attackType, opponentPlayer.Name))
-- Handle Slap Animation Separately
if attackType == "Slap" then
handleSlapAnimation(opponentPlayer, animTrack)
else
local attackerCharacter = opponentPlayer.Character
if not attackerCharacter then return end
local attackerHRP = attackerCharacter:FindFirstChild("HumanoidRootPart")
if not attackerHRP then return end
handleIncomingHit(opponentPlayer, attackerHRP.Position, attackType)
end
end
-- Animation Monitoring: Connect Animation Events
local function monitorAnimations(character, opponentPlayer)
local humanoid = character:FindFirstChildOfClass("Humanoid")
if not humanoid then return end
local connection
connection = humanoid.AnimationPlayed:Connect(function(animTrack)
onAnimationPlayed(animTrack, opponentPlayer)
end)
-- Cleanup when character is removed
character.AncestryChanged:Connect(function(_, parent)
if not parent and connection then
connection:Disconnect()
end
end)
end
-- Hitbox Detection: Handle Hitbox Touched
local function onHitboxTouched(part, attackerPlayer)
if not part or attackerPlayer == LOCAL_PLAYER then return end
local attackerCharacter = part.Parent
if not attackerCharacter then return end
local attackerHRP = attackerCharacter:FindFirstChild("HumanoidRootPart")
if attackerHRP then
debugPrint("Hitbox detected attack from " .. attackerPlayer.Name)
handleIncomingHit(attackerPlayer, attackerHRP.Position, "Default") -- Assuming 'Default' for non-slap attacks
end
end
-- Hitbox Monitoring: Connect Hitbox Events
local function monitorHitboxes(character, attackerPlayer)
local hitboxes = CollectionService:GetTagged(ATTACK_HITBOX_TAG)
for _, hitbox in ipairs(hitboxes) do
if hitbox:IsDescendantOf(character) then
local connection
connection = hitbox.Touched:Connect(function(hitPart)
onHitboxTouched(hitPart, attackerPlayer)
end)
-- Cleanup when hitbox is removed
hitbox.AncestryChanged:Connect(function(_, parent)
if not parent and connection then
connection:Disconnect()
end
end)
-- Remove hitbox after specified time to prevent memory leaks
Debris:AddItem(hitbox, Settings.debrisLifetime)
end
end
end
-- Advanced Reaction System: Continuous Monitoring with Throttling
local function advancedReactionAutoBlock()
if not Settings.autoBlockEnabled then return end
local heartbeatThrottle = 0.05 -- Run logic every 0.05 seconds (20 times per second)
local accumulatedTime = 0
RunService.Heartbeat:Connect(function(deltaTime)
accumulatedTime += deltaTime
if accumulatedTime < heartbeatThrottle then
return
end
accumulatedTime = accumulatedTime - heartbeatThrottle
if not Settings.autoBlockEnabled then return end
local playerCharacter = LOCAL_PLAYER.Character
if not playerCharacter then return end
local playerHRP = playerCharacter:FindFirstChild("HumanoidRootPart")
if not playerHRP then return end
local playerPosition = playerHRP.Position
local camCFrame = CAMERA.CFrame
local camLookVector = camCFrame.LookVector
local camRightVector = camCFrame.RightVector
for _, plr in ipairs(Players:GetPlayers()) do
if plr == LOCAL_PLAYER or not plr.Character or table.find(State.blacklist, plr.Name) or (#State.whitelist > 0 and not table.find(State.whitelist, plr.Name)) then
continue
end
local enemyCharacter = plr.Character
local enemyHRP = enemyCharacter:FindFirstChild("HumanoidRootPart")
if not enemyHRP then continue end
local distance = (playerPosition - enemyHRP.Position).Magnitude
-- Determine maximum relevant distance for this enemy based on attack types
local maxRelevantDistance = Settings.blockDistances.Default
for _, attackType in pairs(Settings.attackTypes) do
local attackDistance = Settings.blockDistances[attackType] or Settings.blockDistances.Default
if attackDistance > maxRelevantDistance then
maxRelevantDistance = attackDistance
end
end
if distance > maxRelevantDistance then continue end
-- Prediction and Direction Update
local predictedPosition = predictEnemyMovement(plr) or enemyHRP.Position
updateBlockDirection(predictedPosition)
local enemyHumanoid = enemyCharacter:FindFirstChildOfClass("Humanoid")
if not enemyHumanoid then continue end
-- Check for active attack animations
for _, animTrack in ipairs(enemyHumanoid:GetPlayingAnimationTracks()) do
local anim = animTrack.Animation
if not anim then continue end
local animId = anim.AnimationId
if not animId then continue end
local numericAnimId = animId:match("rbxassetid://(%d+)")
if not numericAnimId then continue end
numericAnimId = tonumber(numericAnimId)
if not numericAnimId then continue end
local attackType = attackTypesInverse[tostring(numericAnimId)]
if not attackType then continue end
-- Determine if the attack should be considered based on distance
local requiredDistance = Settings.blockDistances[attackType] or Settings.blockDistances.Default
if distance > requiredDistance then continue end
-- Handle Slap Animation Separately
if attackType == "Slap" then
handleSlapAnimation(plr, animTrack)
else
handleIncomingHit(plr, enemyHRP.Position, attackType)
end
end
end
end)
end
-- Player Monitoring: Handle New Players
local function onPlayerAdded(plr)
if plr == LOCAL_PLAYER then return end
local function onCharacterAdded(character)
monitorAnimations(character, plr)
monitorHitboxes(character, plr)
connectCharacterEvents(character)
end
plr.CharacterAdded:Connect(onCharacterAdded)
-- Handle existing character
if plr.Character then
onCharacterAdded(plr.Character)
end
end
-- Initialize Player Monitoring
local function initializePlayerMonitoring()
for _, plr in ipairs(Players:GetPlayers()) do
onPlayerAdded(plr)
end
Players.PlayerAdded:Connect(onPlayerAdded)
end
-- UI Feedback & Directional Block Update
local function updateUIAndDirection()
-- Update UI based on blocking state
local isBlocking = State.isBlocking
UI.LoadingBar.Size = isBlocking and UDim2.new(1, 0, 1, 0) or UDim2.new(0, 0, 1, 0)
UI.LoadingBar.BackgroundColor3 = isBlocking and Settings.ui.LoadingBar.BackgroundColorActive or Settings.ui.LoadingBar.BackgroundColorInactive
UI.MessageBox.Text = isBlocking and "Blocking Active" or (Settings.autoBlockEnabled and "Auto Block Enabled" or "Auto Block Disabled")
end
-- === Swing-Blocking Feature ===
-- Swing-Blocking: Perform Swing and Block
local function performSwingBlock()
if State.isBlocking then
debugPrint("Already blocking. Swing-block aborted.")
showNotification("Already Blocking", 1)
return
end
-- Start Blocking
startBlocking()
-- Simulate Mouse1 Click for Swing
VirtualInputManager:SendMouseButtonEvent(0, 0, Enum.UserInputType.MouseButton1, true, game, 1) -- MouseButton1 Down
task.delay(0.05, function()
VirtualInputManager:SendMouseButtonEvent(0, 0, Enum.UserInputType.MouseButton1, false, game, 1) -- MouseButton1 Up
end)
debugPrint("Swing action simulated.")
showNotification("Swing Action Executed", 1.5)
-- Maintain Blocking State for 0.7 seconds
task.delay(0.7, function()
stopBlocking()
end)
end
-- Input Handling: Manual Blocking, Swing, and Open Settings
local function setupInputHandling()
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == State.customKeyBindings.ToggleBlock then
toggleBlocking()
elseif input.KeyCode == State.customKeyBindings.SwingBlock then
performSwingBlock()
elseif input.KeyCode == State.customKeyBindings.OpenSettings then
UI.SettingsPanel.Visible = not UI.SettingsPanel.Visible
debugPrint("Settings Panel " .. (UI.SettingsPanel.Visible and "Opened" or "Closed"))
end
end)
end
-- Character Cleanup: Handle Character Death or Removal
local function onCharacterRemoved(character)
stopBlocking()
end
local function connectCharacterEvents(character)
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid.Died:Connect(onCharacterRemoved)
end
character.AncestryChanged:Connect(function(_, parent)
if not parent then
stopBlocking()
end
end)
end
local function setupLocalPlayerCharacterMonitoring()
local function onLocalCharacterAdded(character)
connectCharacterEvents(character)
end
if LOCAL_PLAYER.Character then
connectCharacterEvents(LOCAL_PLAYER.Character)
end
LOCAL_PLAYER.CharacterAdded:Connect(onLocalCharacterAdded)
end
-- UI: Setup Key Binding Configuration (Simplified for Example)
local function setupSettingsPanel()
-- For demonstration, we'll create simple buttons to add/remove players from blacklist
-- In a full implementation, you'd include input fields and more complex UI elements
-- Add to Blacklist Button
local addToBlacklistButton = Instance.new("TextButton")
addToBlacklistButton.Size = UDim2.new(0.4, -20, 0.05, -10)
addToBlacklistButton.Position = UDim2.new(0.1, 10, 0.2, 10)
addToBlacklistButton.BackgroundColor3 = Color3.fromRGB(255, 165, 0)
addToBlacklistButton.BackgroundTransparency = 0.3
addToBlacklistButton.BorderSizePixel = 0
addToBlacklistButton.TextColor3 = Color3.fromRGB(255, 255, 255)
addToBlacklistButton.TextScaled = true
addToBlacklistButton.Font = Enum.Font.GothamBold
addToBlacklistButton.Text = "Add Player to Blacklist"
addToBlacklistButton.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
addToBlacklistButton.TextStrokeTransparency = 0.5
addToBlacklistButton.Parent = UI.SettingsPanel
addRoundedCorners(addToBlacklistButton, 8)
-- Remove from Blacklist Button
local removeFromBlacklistButton = Instance.new("TextButton")
removeFromBlacklistButton.Size = UDim2.new(0.4, -20, 0.05, -10)
removeFromBlacklistButton.Position = UDim2.new(0.5, 10, 0.2, 10)
removeFromBlacklistButton.BackgroundColor3 = Color3.fromRGB(220, 20, 60)
removeFromBlacklistButton.BackgroundTransparency = 0.3
removeFromBlacklistButton.BorderSizePixel = 0
removeFromBlacklistButton.TextColor3 = Color3.fromRGB(255, 255, 255)
removeFromBlacklistButton.TextScaled = true
removeFromBlacklistButton.Font = Enum.Font.GothamBold
removeFromBlacklistButton.Text = "Remove Player from Blacklist"
removeFromBlacklistButton.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
removeFromBlacklistButton.TextStrokeTransparency = 0.5
removeFromBlacklistButton.Parent = UI.SettingsPanel
addRoundedCorners(removeFromBlacklistButton, 8)
-- Add to Whitelist Button
local addToWhitelistButton = Instance.new("TextButton")
addToWhitelistButton.Size = UDim2.new(0.4, -20, 0.05, -10)
addToWhitelistButton.Position = UDim2.new(0.1, 10, 0.3, 10)
addToWhitelistButton.BackgroundColor3 = Color3.fromRGB(34, 139, 34)
addToWhitelistButton.BackgroundTransparency = 0.3
addToWhitelistButton.BorderSizePixel = 0
addToWhitelistButton.TextColor3 = Color3.fromRGB(255, 255, 255)
addToWhitelistButton.TextScaled = true
addToWhitelistButton.Font = Enum.Font.GothamBold
addToWhitelistButton.Text = "Add Player to Whitelist"
addToWhitelistButton.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
addToWhitelistButton.TextStrokeTransparency = 0.5
addToWhitelistButton.Parent = UI.SettingsPanel
addRoundedCorners(addToWhitelistButton, 8)
-- Remove from Whitelist Button
local removeFromWhitelistButton = Instance.new("TextButton")
removeFromWhitelistButton.Size = UDim2.new(0.4, -20, 0.05, -10)
removeFromWhitelistButton.Position = UDim2.new(0.5, 10, 0.3, 10)
removeFromWhitelistButton.BackgroundColor3 = Color3.fromRGB(220, 20, 60)
removeFromWhitelistButton.BackgroundTransparency = 0.3
removeFromWhitelistButton.BorderSizePixel = 0
removeFromWhitelistButton.TextColor3 = Color3.fromRGB(255, 255, 255)
removeFromWhitelistButton.TextScaled = true
removeFromWhitelistButton.Font = Enum.Font.GothamBold
removeFromWhitelistButton.Text = "Remove Player from Whitelist"
removeFromWhitelistButton.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
removeFromWhitelistButton.TextStrokeTransparency = 0.5
removeFromWhitelistButton.Parent = UI.SettingsPanel
addRoundedCorners(removeFromWhitelistButton, 8)
-- Functionality for Adding to Blacklist
addToBlacklistButton.MouseButton1Click:Connect(function()
local targetPlayer = Players:GetPlayerFromNameAsync("TargetPlayerName") -- Replace with actual method to get player
if targetPlayer and not table.find(State.blacklist, targetPlayer.Name) then
table.insert(State.blacklist, targetPlayer.Name)
showNotification(targetPlayer.Name .. " added to Blacklist.", 2)
debugPrint(targetPlayer.Name .. " added to Blacklist.")
else
showNotification("Player not found or already blacklisted.", 2)
end
end)
-- Functionality for Removing from Blacklist
removeFromBlacklistButton.MouseButton1Click:Connect(function()
local targetPlayer = Players:GetPlayerFromNameAsync("TargetPlayerName") -- Replace with actual method to get player
if targetPlayer then
for i, name in ipairs(State.blacklist) do
if name == targetPlayer.Name then
table.remove(State.blacklist, i)
showNotification(targetPlayer.Name .. " removed from Blacklist.", 2)
debugPrint(targetPlayer.Name .. " removed from Blacklist.")
break
end
end
else
showNotification("Player not found in Blacklist.", 2)
end
end)
-- Functionality for Adding to Whitelist
addToWhitelistButton.MouseButton1Click:Connect(function()
local targetPlayer = Players:GetPlayerFromNameAsync("TargetPlayerName") -- Replace with actual method to get player
if targetPlayer and not table.find(State.whitelist, targetPlayer.Name) then
table.insert(State.whitelist, targetPlayer.Name)
showNotification(targetPlayer.Name .. " added to Whitelist.", 2)
debugPrint(targetPlayer.Name .. " added to Whitelist.")
else
showNotification("Player not found or already whitelisted.", 2)
end
end)
-- Functionality for Removing from Whitelist
removeFromWhitelistButton.MouseButton1Click:Connect(function()
local targetPlayer = Players:GetPlayerFromNameAsync("TargetPlayerName") -- Replace with actual method to get player
if targetPlayer then
for i, name in ipairs(State.whitelist) do
if name == targetPlayer.Name then
table.remove(State.whitelist, i)
showNotification(targetPlayer.Name .. " removed from Whitelist.", 2)
debugPrint(targetPlayer.Name .. " removed from Whitelist.")
break
end
end
else
showNotification("Player not found in Whitelist.", 2)
end
end)
end
-- === Initialization ===
-- Setup UI
setupUI()
-- Setup Input Handling
setupInputHandling()
-- Initialize Player Monitoring
initializePlayerMonitoring()
-- Setup Local Player Character Monitoring
setupLocalPlayerCharacterMonitoring()
-- Setup Advanced Reaction System
advancedReactionAutoBlock()
-- Setup Settings Panel
setupSettingsPanel()
-- Setup Combined UI Feedback and Directional Block Update
RunService.RenderStepped:Connect(updateUIAndDirection)
-- Notify that the script is running
debugPrint("Autoblock V.4 is now running.")
showNotification("Autoblock V.4 Activated", 2)