----- Functions

local function startBlocking()
	Status = "Blocking"
	game:GetService("SoundService").SFX.Combat.ActivateBlock:Play()

	local vignetteImageLabel = plr.PlayerGui.Vignette.ImageLabel
	game:GetService("TweenService"):Create(vignetteImageLabel, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0), {ImageTransparency = 0}):Play()

	BlockingRemote:FireServer()
	game.TweenService:Create(workspace.CurrentCamera, TweenInfo.new(.3, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {FieldOfView = 60}):Play()
	hum.WalkSpeed = 7
	gaurdingAnimation:Play()
end

local function stopBlocking()
	Status = "nil"
	game:GetService("SoundService").SFX.Combat.ActivateBlock:Play()

	local vignetteImageLabel = plr.PlayerGui.Vignette.ImageLabel
	game:GetService("TweenService"):Create(vignetteImageLabel, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0), {ImageTransparency = 1}):Play()

	debounce = true
	RemoveBlocking:FireServer()
	game.TweenService:Create(workspace.CurrentCamera, TweenInfo.new(.3, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {FieldOfView = 70}):Play()
	hum.WalkSpeed = 16
	gaurdingAnimation:Stop()
	CooldownModule.New("Block", CD)
	task.wait(CD)
	debounce = false
end

UserInputService.InputBegan:Connect(function(input, isProcessed)
	if isProcessed then return end

	if input.KeyCode == Enum.KeyCode.F then
		if not char.Values:FindFirstChild("Stunned") and not debounce then
			if Status == "nil" then
				startBlocking()
			end
		end
	end
end)

UserInputService.InputEnded:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.F and Status == "Blocking" then
		stopBlocking()
	end
end)
