--BROUGHT TO YOU BY RobloxScripter.com!--
if howFar then return end
getgenv().howFar = 40 -- this determines how far a player can be before it will be detected by the auto block (in studs)
local Player = game:GetService("Players").LocalPlayer
local VirtualInputManager = game:GetService("VirtualInputManager")
local Controls = require(game.ReplicatedStorage:FindFirstChild("PlayerControls", true))
local function SendKeyEvent(Key)
VirtualInputManager:SendKeyEvent(true, Key, false, nil)
task.wait(.2)
VirtualInputManager:SendKeyEvent(false, Key, false, nil)
end
for _,player in next, game.Players:GetChildren() do
if player.Character and player.Character.Parent and player.Character.Parent.Parent then
player.Character.HumanoidRootPart.ChildAdded:Connect(function(child)
if Player:DistanceFromCharacter(player.Character.HumanoidRootPart.Position) <= howFar and (string.find(child.Name, "SFX_Swing") or string.find(child.Name, "SFX_Kick")) then
SendKeyEvent(Controls.Block)
end
end)
end
player.CharacterAdded:Connect(function(character)
character:WaitForChild("HumanoidRootPart").ChildAdded:Connect(function(child)
if Player:DistanceFromCharacter(player.Character.HumanoidRootPart.Position) <= howFar and (string.find(child.Name, "SFX_Swing") or string.find(child.Name, "SFX_Kick")) then
SendKeyEvent(Controls.Block)
end
end)
end)
end
while true do -- keep controls updated
Controls = require(game.ReplicatedStorage:FindFirstChild("PlayerControls", true))
task.wait(1)
end