Jump to content

Check if a button gets pressed repeatedly


Recommended Posts

Hi! I have a question. How can I check if a button, for example L Shift gets pressed repeatedly? Because I want to do a function if I hold down a key the character starts jogging, but if I keep pushing it the character starts to sprint. How could I do this? Does anyone could help me in this please? Thank you!

Link to comment

Okay, so I made a script, but my problem is that I don't know how to get the player's sprint key. So for example my sprint is binded to left shift, but other players have other binds, for example my friend's sprint key is space. How can I get the sprint button and bind it? So everyone can use it with their binds.

Right now I have this:

  
bindKey( "lshift", "both", 
function () 
    if getKeyState("lshift") == true then 
        setControlState ( "walk", false ) 
        setControlState ( "sprint", false ) 
        outputChatBox("jogging") 
    elseif getKeyState("lshift") == false then 
        setControlState ( "walk", true ) 
        setControlState ( "sprint", false ) 
        outputChatBox("walking") 
    end 
end ) 
  

And I want to make the script work like if you keep pressing the sprint button the character starts to sprint, but if you just hold it your character will be jogging and if you don't hold or press it then your character just simply walks. Can anybody help me in this please?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...