Help disabling sprinting while crawling

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

  2. What is the issue? Include screenshots / videos if possible!

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

-- This is an example Lua code block

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

Can’t you just create a boolean variable and make it true the player is crouching and make it false when they stop crouching and just check that?


You could make a boolean value and check if the boolean value is true when the player presses the sprint key.
Just change the boolean value to true/false on the crawl script.
I just read the reply above me…


I don’t know much about what u said but I will watch some vids about it thank you so much

Sorry to be a bother but how do I make a boolean

A boolean is a simple true or false variable:

local boolean = true
local boolean = false
1 Like

Ok one more question I know I’m probably bothering you but I ain’t good at scripting which script would I put this in? The crawling or the sprinting

You’d do something like this:

uis.InputBegan:Connect(function(input, proccess)
    if input.KeyCode == Enum.KeyCode.LeftShift and not crouching then
      -- 'crouching' would the boolean variable to check
      -- code to sprint here

You’re not.

In the function that makes the player crouch, you can do this when they enable it:

crouching = true

and this when they disable it:

crouching = false
1 Like

im getting that error

Switch uis with UserInputService

Bruh my wifi cut out can I text u back in like 10 mins?

And before it cut out I tryed what u said and it was still red

Actually, there’s another problem, don’t wrap the entire script under the UserInputService.InputBegan. What I meant by -- code to sprint here was to call the function that makes the player sprint, not the entire script.


Like this ^

Ohhh my bad sorry I will try it when I come back my wifi is being dumb thanks for helping me I will let u know soon

1 Like

My wifi is being very bad but my function for my sprint would be “sprint” right?

It’s what you set it to, in this case, yes, because that’s how it’s declared:

Yea my wifi isn’t working I can still create just not save my game so ima write the scipy and send u a picture and can U tell me if it’s right? Also how do I send pics on mobile

Don’t mind the errors at the bottom it happens every time my wifi stops working but I did everything u told me to tell me what I did wrong

Very sorry I’m if im bothering I really want this to be fixed

Put the new event listener near the bottom of the script and remove the old one. The listener should look like this:

uis.InputBegan:Connect(function(input, processed)
   if input.KeyCode == Enum.KeyCode.LeftShift and not crouching then
       sprint("Began") -- lowercase 's' ; variable names are case-sensitive