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

Can't find any method to make a shift to sprint. Help?

Asked by
VVired 28
7 years ago
Edited 7 years ago

I've been trying many methods, none of them work. I'm not asking for a script I am asking for a direction that works. Thank you.

EDIT:

I made a script, but it still doesn't seem to work.

local userinput = game:GetService("UserInputService")
local hum = game.Players.LocalPlayer.Character.Humanoid

userinput.InputBegan:connect(function(input)
    if Enum.KeyCode.LeftShift then
        hum.WalkSpeed = 60
    else
        hum.WalkSpeed = 16
    end
end)

1 answer

Log in to vote
0
Answered by 7 years ago

Hey VVired,

You have the correct event you are working with to make what you want however, you are failing to check the parameters correctly. UserInputService has 2 parameters in them: input object(The key that is pressed) and game processed event (To check if the player was typing while he/she pressed the key, this is a boolean value). Anyway, if you click on the 'UserInputService' text anywhere in this answer, you will get linked to a wiki page to explain how you can use UserInputService however, I will show you a personal example below as to how you can do what you are asking. This is an example so, it's not gonna necessarily fulfill the ambitions of your code.

Example:

local uis = game:GetService("UserInputService") -- Declares a variable for UserInputService

uis.InputBegan:Connect(function(obj, gp) -- Declares the anonymous function.
if obj.KeyCode == Enum.KeyCode.Q and not gp then -- Checks if 'Q' was pressed and checks if 'Q' was meant to be pressed. If 'Q' was pressed while typing in chat, this if statement shouldn't allow the function to proceed any further.
print("Q was pressed.") -- Prints "Q was pressed." in the output.
end -- end for the if statement
end) -- end for the anonymous function. That parenthesis is necessary because, that's how you end anonymous functions.

Well, I hope I helped in one way or another, if you have any questions or concerns please don't hesitate to leave a comment down below and have a great day/night.

~~ KingLoneCat

0
Why doesn't Left Shift work? VVired 28 — 7y
0
It should be able to work. Type 'Enum.KeyCode.' and it should pop up all the options you can possibly press. The code in the answer is just an example, like I said it's not necessarily gonna give you the answer. KingLoneCat 2642 — 7y
Ad

Answer this question