i have a idea where if you press a twice you dash left if you press s twice you dash backwards etc, but i have no idea how i would make it. i thought it was a cool idea any help would be nice.
You could use UserInputService to detect keyboard input and tick() to differentiate how much time has passed when pressing a key twice.
https://developer.roblox.com/en-us/api-reference/class/UserInputService
Use InputBegan
to connect the function and use IsKeyDown
to know if you use that combination.
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(Input, Chat)
if UIS:IsKeyDown(Enum.KeyCode.Q) and UIS:IsKeyDown(Enum.KeyCode.E) then
print("Convination of Q + E")
end
end)
you can start off with something like this
local last = tick()
local dashing = false
game:GetService("UserInputService").InputBegan:Connect(function(input, gp)
if gp then return end
if input.KeyCode == Enum.KeyCode.W then
if (tick() - last)< 0.5 then
if not dashing then
dashing = true
--dashing script
else if dashing then
print("Was Already Dashing")
return
end
wait(1)
dashing = false
end
end
last = tick()
end
end)
This will detect if you pressed w twice and I hope you know what to do for the rest:)
thank you! i will try this right now.