Tap to sprint not hold

the script below makes the player faster when holding down ctrl. is it possible that it isnt necesarry to hold it down and just tap ctrl once to go faster and tap again to slow down again?

local Player = game.Players.LocalPlayer
local	Character = Player.Character
local UserInputService = game:GetService("UserInputService")
local Speed = 25



UserInputService.InputBegan:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.LeftControl then
		Character.Humanoid.WalkSpeed = Speed
		
	end
end)
UserInputService.InputEnded:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.LeftControl then
		Character.Humanoid.WalkSpeed = 16
	end
end)

yes, it is possible for being able to tap for speed. Here is a script for it:

local Player = game.Players.LocalPlayer
local	Character = Player.Character
local UserInputService = game:GetService("UserInputService")
local Speed = 25



UserInputService.InputBegan:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.LeftControl then
		if Character.Humanoid.WalkSpeed == Speed then
			Character.Humanoid.WalkSpeed = 16
		else
			Character.Humanoid.WalkSpeed = Speed 
		end
	end
end)
2 Likes