Permanent (Unintended) Speed Increase

I have a problem with the interaction of these two scripts on my server.

When I sprint or block individually, everything works fine. However, when I sprint and then hold block at the same time, and undo the sprint, my Walkspeed becomes faster permanently.

How do I stop it from permanently speeding up after sprint AND block are used at the same time?

Server Script (Sprinting)

--Variables:

local remote = game.ReplicatedStorage.PyrSprint

local activated = false

local originalspd = nil

local TweenService = game:GetService("TweenService")

--Settings:

--Script:

remote.OnServerEvent:Connect(function(player)
	print(player,"has reached the server")
	local char = player.Character 
	if activated == false then
		originalspd = char.Humanoid.WalkSpeed
		
		local Run = {}
		Run.WalkSpeed = char.Humanoid.WalkSpeed * 1.5 

		local tweenInfo = TweenInfo.new(1.15,Enum.EasingStyle.Quad,Enum.EasingDirection.In)

		local RunTween = TweenService:Create(char.Humanoid, tweenInfo, Run)

		RunTween:Play()
		
		activated = true
		
	elseif activated == true then
		local Slow = {}
		Slow.WalkSpeed = originalspd

		local tweenInfo = TweenInfo.new(1.15,Enum.EasingStyle.Quad,Enum.EasingDirection.Out)

		local SlowTween = TweenService:Create(char.Humanoid, tweenInfo, Slow)

		SlowTween:Play()
		
		activated = false
	end
end)

Local Script (Sprinting)

--Variables:

local remote = game.ReplicatedStorage.PyrSprint

local UserInputService = game:GetService("UserInputService")

local activated = false

local cam = workspace.Camera

local TweenService = game:GetService("TweenService")

--Settings:

--Script:

UserInputService.InputBegan:Connect(function(input,gameProcessed)
	if gameProcessed == false then
		if input.KeyCode == Enum.KeyCode.LeftAlt and activated == false then
			print("You're speeding up!")
			activated = true
			
			
			local FOV = {}
			FOV.FieldOfView = 90

			local tweenInfo = TweenInfo.new(1.25,Enum.EasingStyle.Quad,Enum.EasingDirection.In)

			local RunTween = TweenService:Create(cam, tweenInfo, FOV)

			RunTween:Play()
			
			remote:FireServer()
			
		
		elseif activated == true and input.KeyCode == Enum.KeyCode.LeftAlt then
			local slowFOV = {}
			slowFOV.FieldOfView = 70

			local tweenInfo = TweenInfo.new(1.25,Enum.EasingStyle.Quad,Enum.EasingDirection.Out)

			local slowTween = TweenService:Create(cam, tweenInfo, slowFOV)

			slowTween:Play()
			
			print("YOOOO IT WORKED")
			activated = false
			remote:FireServer()
		
			end
	else end
end)

Server Script (Blocking)

--Variable:

local remote = game.ReplicatedStorage.pyrBlock



--Settings:
local activated = false
local onCooldown = false
local originalspd = nil

--Script:

remote.OnServerEvent:Connect(function(player)
	
	local char = player.Character 
	print(player,"has reached the server")
	
	if activated == false and onCooldown ~= true then
		
		originalspd = char.Humanoid.WalkSpeed
		
		char.Humanoid.WalkSpeed = char.Humanoid.WalkSpeed * .5
		
		local IsBlocking = Instance.new("BoolValue")
		IsBlocking.Name = "IsBlocking"
		IsBlocking.Parent = char
		IsBlocking.Value = true
		
		activated = true
		
	elseif activated == true and onCooldown ~= true then
		
		activated = false
		
		char.IsBlocking:Destroy()
		
		char.Humanoid.WalkSpeed = originalspd
		
		onCooldown = true
		wait(.5)
		onCooldown = false
		
	end
end)

Local Script (Blocking)

-- Variables --

local player = game.Players.LocalPlayer

local blockAnimation = Instance.new("Animation")
blockAnimation.AnimationId = "rbxassetid://7368182945"

local Remote = game.ReplicatedStorage.pyrBlock
local UserInputService = game:GetService("UserInputService")

-- Settings --

local blocking = false

local onCooldown = false


-- Script --

UserInputService.InputBegan:Connect(function(input, gameprocessed)
	if gameprocessed == false then
	
		if UserInputService:IsKeyDown(Enum.KeyCode.F) and blocking == false and onCooldown ~= true then
			
			local char = player.Character

			blockTrack = char.Humanoid:LoadAnimation(blockAnimation)
			
			blockTrack:Play()
			
			Remote:FireServer()
			
			print("You've fired to the server!")
			blocking = true
	else end
	end
end)
	
UserInputService.InputEnded:Connect(function(input, gameprocessed)
	if gameprocessed == false then

		if UserInputService:IsKeyDown(Enum.KeyCode.F) == false and blocking == true and onCooldown ~= true then
			
			blocking = false
			
			blockTrack:Stop()
			Remote:FireServer()
			print ("You're back!")	
			
			onCooldown = true
			wait(.5)
			onCooldown = false
	else end
	end
end)

I think it has to do something with the originalspeed variable being set to a lower number since you’re blocking, or a higher one, since you’re sprinting

I don’t know the fix for it though :sweat_smile:

Yeah I know that’s the problem, I just cant figure out a way to fix it