Crawling System Bug For Mobile Players

I’ve been working on a crawl + crouch system, it’s been going fine, no bugs with PC or anything, but with the mobile support UI, whenever you crawl it works fine, it’ll slow you down and play the animation, but when you get back up, you are still slow, it’s cause I haven’t implemented the code to do that, as I do not know how, please do not try completely re-writing the code, just edit the small portion in order to add in speeding up once you’re no longer crawling. This is what the code looks like and how it’s set up.
image

local UIS = game:GetService("UserInputService")

local player = game.Players.LocalPlayer
local char = player.Character
local hum = char:WaitForChild("Humanoid")
local animPlay = hum.Animator:LoadAnimation(script:WaitForChild("Animation"))
local crouch = hum.Animator:LoadAnimation(script:WaitForChild("crouch"))
local isCrawling = false

hum.Running:Connect(function(speed)
	if speed > 0 then
		animPlay:AdjustSpeed(speed/6)
		crouch:AdjustSpeed(speed/6)
	else
		animPlay:AdjustSpeed(0)
		crouch:AdjustSpeed(0)
	end
end)



local act = game:GetService("ContextActionService")

function toggle(name, state, animtype)
	if state and state ~= Enum.UserInputState.Begin then return end
	local anim = animtype
	if typeof(animtype)=="Instance" and animtype:IsA("InputObject") then
		anim = (animtype.KeyCode == Enum.KeyCode.X and crouch) or animPlay
	end
	if hum:GetState()~=Enum.HumanoidStateType.Running then isCrawling = true end
	if not isCrawling then
		isCrawling = true
		hum.HipHeight = (anim == animPlay and 0.6) or 2
		anim:Play()
		hum.WalkSpeed = 8
	else
		isCrawling = false
		hum.HipHeight = 2
		animPlay:Stop()
		crouch:Stop()
		hum.WalkSpeed = 16
	end
end

hum.StateChanged:Connect(function(old, new)
	if new ~= Enum.HumanoidStateType.Running then
		toggle()
	end
end)

script.Parent.Activated:Connect(function()
	toggle(nil, nil, animPlay)
	hum.WalkSpeed = 8
end)

script.Parent.Parent.Parent.Crouch.ImageButton.Activated:Connect(function()
	toggle(nil, nil, crouch)
	hum.WalkSpeed = 8
end)

act:BindAction("Crawl", toggle, false, Enum.KeyCode.C, Enum.KeyCode.LeftControl, Enum.KeyCode.X)

Yes, sprinting while crawling is patched with other code, here’s the patch for the mobile support with their mobile UI.
image

script.Parent.MouseButton1Click:Connect(function()
	-- normal
	if game.Players.LocalPlayer.Character.Humanoid.WalkSpeed == 26 then
		game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
	end
	if game.Players.LocalPlayer.Character.Humanoid.WalkSpeed == 16 then
		game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 26
	end
	-- crawling
	if game.Players.LocalPlayer.Character.Humanoid.WalkSpeed == 8 then
		game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 10
	end	
	if game.Players.LocalPlayer.Character.Humanoid.WalkSpeed == 10 then
		game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 8
	end
	-- arrested
	if game.Players.LocalPlayer.Character.Humanoid.WalkSpeed == 0 then
		game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0
	end
end)

And here’s the PC patch, in the shift to sprint code.
image

-- Services
local inputService = game:GetService("UserInputService")
local playerService = game:GetService("Players")

-- Objects
local plr = playerService.LocalPlayer
local char = plr.Character or plr.CharacterAdded:wait()
local settingsDir = script.Settings

function getSetting (name)
	return settingsDir and settingsDir:FindFirstChild(name) and settingsDir[name].Value
end

local normalSpeed = getSetting("Walking speed") or 16 -- The player's walking speed (Roblox default is 16)
local sprintSpeed = getSetting("Running speed") or 26 -- The player's speed while sprinting
local crawlingSpeed = getSetting("Crawling speed") or 8 -- The player's speed while crawling
local speedCrawling = getSetting("Speed Crawling speed") or 10 -- The player's speed while sprinting while crawling
local arrestedSpeed = getSetting("arrested speed") or 0 -- The player's speed when arrested

local sprinting = false

inputService.InputBegan:Connect(function (key)
	if key.KeyCode == Enum.KeyCode.LeftShift or key.KeyCode == Enum.KeyCode.RightShift then
		running = true
		if char:FindFirstChild("Humanoid") then
			if char.Humanoid.WalkSpeed == crawlingSpeed then
				char.Humanoid.WalkSpeed = speedCrawling
			else
				if char.Humanoid.WalkSpeed == arrestedSpeed then
					char.Humanoid.WalkSpeed = arrestedSpeed
				else
					char.Humanoid.WalkSpeed = sprintSpeed
				end
			end
		end
	end
end)

inputService.InputEnded:Connect(function (key)
	if key.KeyCode == Enum.KeyCode.LeftShift or key.KeyCode == Enum.KeyCode.RightShift then
		running = false
		if char:FindFirstChild("Humanoid") then	
			if char.Humanoid.WalkSpeed == speedCrawling then
				char.Humanoid.WalkSpeed = crawlingSpeed
			else
				if char.Humanoid.WalkSpeed == arrestedSpeed then
					char.Humanoid.WalkSpeed = arrestedSpeed
				else
					char.Humanoid.WalkSpeed = normalSpeed
				end
			end
		end
	end
end)

Please, I really need this patched, HELP!