Sprinting by double tapping a key!

By pressing “w” twice within the duration of MAX_DOUBLE_DURATION then, you will enter sprinting mode. The DEBOUNCE_DURATION is just a delay to sprint very fast.

Create a local script and place it in StarterPlayerScripts. Hopefully this helps people out.

--services
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")

--constants
local PLAYER = Players.LocalPlayer

local MAX_DOUBLE_DURATION = .2 -- tiem to press "w" again
local DEBOUNCE_DURATION = .5 -- delay

local NORM_SPEED = 16
local RUN_SPEED = 25

--variables
local lastTick = tick()
local debounce = false
local running = true

--functions
function getCharacter()
	return PLAYER.Character or PLAYER.CharacterAdded:Wait()
end

function changeSpeed(speed)
	local character = getCharacter()
	local humanoid = character:FindFirstChild("Humanoid")
	humanoid.WalkSpeed = speed
end

function activate()
	if debounce == false then
		if tick() - lastTick <= MAX_DOUBLE_DURATION then
			debounce = true
			running = true
			changeSpeed(RUN_SPEED)
		end
		lastTick = tick()
	end
end

--events
UserInputService.InputBegan:Connect(function(input,gameProcessedEvent)
	if input.KeyCode == Enum.KeyCode.W then
		activate()
	end
end)

UserInputService.InputEnded:Connect(function(input,gameProcessedEvent)
	if input.KeyCode == Enum.KeyCode.W then
		if running then
			running = false
			changeSpeed(NORM_SPEED)
			wait(DEBOUNCE_DURATION)
			debounce = false
		end
	end
end)
40 Likes