Need help with context action service

I tried making a toggle button for mobile users to sprint when you press it it does actually sprint but if you press it again nothing happens you stay sprinting I hope you understood
So how can I make it toggle?
Here is my code:

local ContextActionService = game:GetService("ContextActionService")
local char = game.Players.LocalPlayer.Character

local function Sprint()
	char.Humanoid.WalkSpeed = 26
end

ContextActionService:BindAction("Sprint", Sprint, true, Enum.KeyCode.LeftShift)

Try this.

local ContextActionService = game:GetService("ContextActionService")
local char = game.Players.LocalPlayer.Character
local toggle = 0

local function Sprint()
     if toggle == 0 then
	char.Humanoid.WalkSpeed = 26
        toggle = 1
    else 
	char.Humanoid.WalkSpeed = 16 -- default walk speed
        toggle = 0
     end
end

ContextActionService:BindAction("Sprint", Sprint, true, Enum.KeyCode.LeftShift)

Do I need to hold the button down?

No, when the function Sprint() is called (once), it will change the walk speed to either run or walk, based on if the speed is currently 26 or 16.

Well when I tried it,
It only works when I hold it down but you know what? I’m fine with it at least it works

Sorry I misunderstood, one moment please.

local UserInputService = game:GetService("UserInputService")
local char = game.Players.LocalPlayer.Character
local toggle = 0

UserInputService.InputBegan:Connect(function(input, isTyping)
	if not isTyping then
		if input.KeyCode == Enum.KeyCode.LeftShift then
			if toggle == 0 then
				char.Humanoid.WalkSpeed = 26
				toggle = 1
			else 
				char.Humanoid.WalkSpeed = 16 -- default walk speed
				toggle = 0
			end
		end
	end
end)


You can do this to toggle key on PC. You may have to utilize some other code on mobile, however I am not particularly good at mobile development.