Character is stuck when blocking and sprinting at the same time

https://gyazo.com/a1797026abd53a274f89ae42e85a9347

UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift then
		human.WalkSpeed = 19
	
		for i,command in pairs(commands) do
			command.Disabled = true
		end
		if human.MoveDirection.Magnitude > 0 then
			
			tweening:Play()
			Sprintanimtrack:Play(0.1,1,1.25)
			
		end
	end
end)

UIS.InputEnded:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift then
		human.WalkSpeed = 12
		for i,command in pairs(commands) do
			command.Disabled = false
		end
		tweening2:Play()
		Sprintanimtrack:Stop()
	end
end)
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BlockAnim = ReplicatedStorage.Animations.Block
local BlockAnimTrack = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(BlockAnim)
local BlockEvent = ReplicatedStorage.RemoteEvents.Combat.Block
local BlockEventStop = ReplicatedStorage.RemoteEvents.Combat.BlockStop

local player = game.Players.LocalPlayer

UserInputService.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton2 then
		BlockAnimTrack:Play()
		BlockEvent:FireServer()
	end
end)

UserInputService.InputEnded:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton2 then
		BlockEventStop:FireServer()
		BlockAnimTrack:Stop()
	end
end)

local function BlockStart (player,commands)
		player.Character.Humanoid.WalkSpeed = 8
	
		for i,tool in pairs(player.Backpack:GetChildren()) do
			tool.Enabled = false
			if tool:FindFirstChildWhichIsA("LocalScript") then
				tool:FindFirstChildWhichIsA("LocalScript").Disabled = true
			end
		end

		for i,command in pairs(commands) do
			command.Disabled = true
		end
end

local function BlockStop (player,commands)
	player.Character.Humanoid.WalkSpeed = 12
	
	for i,tool in pairs(player.Backpack:GetChildren()) do
		tool.Enabled = true
		if tool:FindFirstChildWhichIsA("LocalScript") then
			tool:FindFirstChildWhichIsA("LocalScript").Disabled = false
		end
	end

	for i,command in pairs(commands) do
		command.Disabled = false
	end
end

Block.OnServerEvent:Connect(function(player)
	local BlockValue = Instance.new("StringValue")
	BlockValue.Name = player.Name
	BlockValue.Parent = BlockingList	
	
	local commands = {
		sprint = player.Character.Sprint,
		dash = player.Character.Dash,
	}
	
	BlockStart(player,commands)
end)

BlockStopEvent.OnServerEvent:Connect(function(player)
	local BlockValue = BlockingList:FindFirstChild(player.Name)
	
	if BlockValue then

		local commands = {
			sprint = player.Character.Sprint,
			dash = player.Character.Dash,
		}
		
		BlockStop(player,commands)
		
		BlockValue:Destroy()
	end
end)

i tried to disable sprinting when blocking and vice versa but it still got stuck

1 Like