Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
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

Log in to vote
0
Answered by
kisty1 111
4 years ago
Edited 4 years ago

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)
Ad

Answer this question