I've tried changing r to ww but it just doesn't work. This is my current script and R is just a place holder key until I can change it to double w.
local player = game.Players.LocalPlayer local character = player.Character local humanoid = character.Humanoid local mouse = player:GetMouse() local origSpeed = humanoid.WalkSpeed local runSpeed = 30 --change for faster or slower
mouse.KeyDown:connect(function(key) if key:lower() == "r" then humanoid.WalkSpeed = runSpeed end end) mouse.KeyUp:connect(function(key) if key:lower() == "r" then humanoid.WalkSpeed = origSpeed end end)
The script works perfectly fine, it's just that I want the R to be a double W tap.
If you want the key to be pressed twice, you can make a variable that checks if it was previously.
local CAS = game:GetService("ContextActionService") --A game service responsible to bind and unbind a action. local isPressedOnce = false local function dash(actionName,inputState,inputObject) if inputState == Enum.UserInputState.Begin then if isPressedOnce == false then -- when the "w" is pressed the first time, this statement will be true. isPressedOnce = true --this will allow the statement below to be true wait(1) isPressedOnce = false elseif isPressedOnce == true then --if the button is pressed the second time, it will run. --dash isPressedOnce = false end end end Cas:BindAction("Dash"--[[Action Name--]],dash--[[function--]],false--[[if this is true, it will make a dash button on mobile device--]],Enum.KeyCode.W--[[key to activate the function--]])
This way, it will detect your key to be pressed, and if this is the second time pressed it will fire.
Also, I think you should use ContextActionService
as I did in the example.