--//Other//--

local UserInputService = game:GetService("UserInputService")
local Equipped = false
local event = script.Parent.Blocking
local event2 = script.Parent.BlockingStop
local blocking = false
local debounce = false

tool.Equipped:Connect(function()
	Equipped = true
	UserInputService.InputBegan:Connect(function(Input,Typing)
		if Typing == false and Input.KeyCode == Enum.KeyCode.E and Equipped == true and blocking == false and debounce == false then
			blockstarttrack:Play()
			hum.WalkSpeed = 6
			debounce = true
			blockholdtrack:Play()
			event:FireServer(hum)
			blocking = true
			wait(4)
			event2:FireServer(hum)
			blockholdtrack:Stop()
			hum.WalkSpeed = 16
			wait(1)
			debounce = false
			blocking = false
		end
		if Typing == false and Input.UserInputType == Enum.UserInputType.MouseButton1 and Equipped == true then
			event2:FireServer(hum)
			blockholdtrack:Stop()
			hum.WalkSpeed = 16
			debounce = false
			blocking = false
		end
	end)
end)

tool.Unequipped:Connect(function()
	Equipped = false
	if blocking == true then
		hum.WalkSpeed = 16
		event2:FireServer(hum)
		blockholdtrack:Stop()
		blocking = false
		debounce = false
	end
end)
