Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Userinput double tapping w with tick not working with no errors what did i do wrong?

local player = game:GetService("Players").LocalPlayer
local hum = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
local WS = 16
local SB = 21
local Input = game:GetService("UserInputService")
local SprintW = tick()

Input.InputBegan:connect(function(Run)
	if Run.KeyCode == Enum.KeyCode.W then
		local Hit = tick()
		local TimeBetween = (SprintW - Hit)
		if TimeBetween <= 0.2 then
			hum.WalkSpeed = 21
		end
	end
end)

I followed some things i found online about tick and such and i really thought that this was gonna work but for some reason it feels like every script i make just doesn't work even when i get no errors did i do something wrong here? The local script is in StarterGui

1 answer

✓ Accepted answer

The value of SprintW is never changed, Set it to the value returned by tick() if TimeBetween is greater than 0.2

local player = game:GetService("Players").LocalPlayer
local hum = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
local WS = 16
local SB = 21
local Input = game:GetService("UserInputService")
local SprintW = tick()

Input.InputBegan:connect(function(Run)
    if Run.KeyCode == Enum.KeyCode.W then
        local Hit = tick()
        local TimeBetween = (SprintW - Hit)
        if TimeBetween <= 0.2 then
            hum.WalkSpeed = 21
		else
			SprintW = tick()
        end
    end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.