I know how to make a character go faster i just need to figure out how to do keypresses and all that help please
COMMUNITY QUESTION
How do I do key presses like if someone presses the shift key they sprint?
2 answers
Well, to detect when you press a key, you need use a function called KeyCode, you can see this article for more information : https://wiki.roblox.com/index.php?title=API:Enum/KeyCode
I use this type of KeyCode in my scripts :
if key.KeyCode == Enum.KeyCode.Z then
end
you can change the "Z" for the key that you want, and this function need be in a LocalScript
Hello Tacodragon777, you can use the Service called "UserInputService" to deal with keys heres an example below
local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then-- you can change the letter "E" to any other Key
--then put what happens down here like
print("It works!")
2 comments
0
maybe belew the then, you can put game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = game.Players.LocalPlayer.Character.Humanoid.WalkSpeed + 20
0
And By the Way.This IS a Local Script.
This discussion is preserved as it was. New answers, comments, and votes are closed.

8 comments
oh, i usually put the script in GUIs, but i think that this can work with StarterPlayersScripts too, Backpack and etc.
i think you can also you key byte codes but i dont know if thats deprecated or not
It is deprecated
How would i do this for shift do i just change Z to Shift?
yes
Please, if this answer is good to you, mark as accepted, thanks ^^ (you need use LeftShift or RightShift instead of Z)
Ok how would i make it stop sprinting when they release LeftShift?
uif = game:GetService("UserInputService") / use this = uif.InputEnded:connect(function(imput)