Requiring Crouch Script

Hello! I am trying to disable the Sprinting Script whenever the player is crouching by pressing C. I thought requiring the Crouch Script inside of the Sprinting script would work but I am receiving this error:

“Attempted to call require with invalid argument(s).”

Here are the Scripts:

Crouch Script:

local UIS = game:GetService('UserInputService')
local Character = script.Parent
local Humanoid = Character:WaitForChild('Humanoid')
local Animations = Instance.new('Configuration', Character)


if Humanoid.RigType == Enum.HumanoidRigType.R6 then

	Animations.Name = 'Animations2'
	local CrouchAnimation = Instance.new('Animation', Animations)
	CrouchAnimation.AnimationId = 'rbxassetid://14961638635'
	CrouchAnimation.Name = 'CrouchAnimation'
	local LoadCrouchAnimation = Humanoid:LoadAnimation(CrouchAnimation)
	LoadCrouchAnimation.Looped = true

	local function IsCrouching()
		return Humanoid.WalkSpeed == 5
	end

	UIS.InputBegan:Connect(function(Input)
		if Input.KeyCode == Enum.KeyCode.C then
			if Humanoid.Health > 0 then
				Humanoid.WalkSpeed = 5 
				Character.HumanoidRootPart.Running.PlaybackSpeed = 0.70
				LoadCrouchAnimation:Play()

				while wait() do
					if Humanoid.MoveDirection.Magnitude > 0 then
						LoadCrouchAnimation:AdjustSpeed(0.5)
					else
						LoadCrouchAnimation:AdjustSpeed(0)
					end
				end
			end
		end
	end)

	UIS.InputEnded:Connect(function(Input)
		if Input.KeyCode == Enum.KeyCode.C then
			LoadCrouchAnimation:Stop()
			Character.HumanoidRootPart.Running.PlaybackSpeed = 1
			Humanoid.WalkSpeed = 8
		end
	end)

	return {
		IsCrouching = IsCrouching
	}
end

Sprinting Script:

local SPRINT_SPEED = 18
local DEFAULT_SPEED = 8
local MAXIMUM_STAMINA = 100

local STAMINA_DECREASE = 0.3
local SPRINT_KEY = Enum.KeyCode.LeftShift

local UserInputService = game:GetService("UserInputService")

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local Humanoid = Character:WaitForChild("Humanoid")

local Exterior = script.Parent.Exterior
local Bar = Exterior.Bar

local OutofBreath = script.OutofBreath

local Sprinting = false
local StaminaAmount = MAXIMUM_STAMINA

local CrouchScript = require(game.StarterPlayer.StarterCharacterScripts:WaitForChild("CrouchScript"))

local function PlayOutOfBreathSound()

	if StaminaAmount <= 0 and not OutofBreath.IsPlaying then
		OutofBreath:Play()
	end
end

UserInputService.InputBegan:Connect(function(Key, Processed)
	if not Processed then
		if Key.KeyCode == SPRINT_KEY then
			-- Player is sprinting.

			Sprinting = true
		end
	end
end)

UserInputService.InputEnded:Connect(function(Key, Processed)
	if not Processed then
		if Key.KeyCode == SPRINT_KEY then
			-- Player stopped sprinting.

			Sprinting = false
		end
	end
end)

game["Run Service"].RenderStepped:Connect(function()
	if not CrouchScript:IsCrouching() then
		if StaminaAmount > 0 then 
			if Sprinting then 
				if Humanoid.MoveDirection.Magnitude > 0 then
					Humanoid.WalkSpeed = SPRINT_SPEED
					StaminaAmount -= STAMINA_DECREASE
				end
			else
				Humanoid.WalkSpeed = DEFAULT_SPEED
			end
		else
			Humanoid.WalkSpeed = DEFAULT_SPEED
		end

		if StaminaAmount < MAXIMUM_STAMINA then
			-- do something.
			Exterior.Visible = true

			local Formula = (StaminaAmount/MAXIMUM_STAMINA)
			Bar:TweenSizeAndPosition(UDim2.new(1, 0, Formula, 0), UDim2.new(0, 0, 1-Formula, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.1, true)

			if not Sprinting then
				StaminaAmount += STAMINA_DECREASE
			end
		else
			-- Hide if full.

			Exterior.Visible = false
		end
	else
		Humanoid.WalkSpeed = DEFAULT_SPEED -- Reset WalkSpeed if crouching
	end

	PlayOutOfBreathSound()
end)

the issue might’ve been caused because the crouch script isn’t a module script. Try putting them in the same script maybe??

I would do the same thing. By putting them in the same script you could also add more customization like slower sprinting while you’re crouching.