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

How To increase Walkspeed when you press shift?

Asked by 6 years ago
Edited 6 years ago

I am trying to make a horror game and i need to know how to increase walkspeed (and other stuff like camera bobbing) when you press shift. btw i already have a first person torso, legs and arms script.

repeat wait() until game.Players.LocalPlayer
local player = script.Parent.Parent
local mouse = player:GetMouse()
mouse.KeyDown:connect(function(key)
    if key == "e" then
--Despacito here 

2 answers

Log in to vote
0
Answered by 6 years ago

I would actually recommend using userinputservice, yes it is more writing but at least you won't bother by checking all the time which numbers were space, control or in your case shift, also i've heard that it doesn't work anymore and im too lazy to check so there is this one:

wait() --- wait for player to load
local human = script.Parent:FindFirstChild("Humanoid") ---- find humanoid inside player
local UserInputService = game:GetService("UserInputService") --- get userinputservice


 UserInputService.InputBegan:Connect(function(inputObject, gameProcessed) -- use userinputservice in a fuction where the button was pressed
     if inputObject.KeyCode == Enum.KeyCode.LeftShift then  --- check if button is shift
        human.WalkSpeed = 60 --- change how fast to move
    end
end)

UserInputService.InputEnded:Connect(function(inputObject, gameProcessed)  -- use userinputservice in a fuction where the button was released
    if inputObject.KeyCode == Enum.KeyCode.LeftShift then -- check if button is shift
        human.WalkSpeed = 16 --- change the speed to normal
    end
end)

NOTE: in order for this script to work it must be in StarterPlayer>StarterCharacterScripts or StarterPack also note out that it must be localscript and it must not stay inside of another model/script/tool/etc.

0
use if not gameProcessed then ... yHasteeD 1819 — 6y
0
@yHasteeD ye, that might be an option but i just enjoy making the scripts long, scripting gives me joy so the longer the more fun for me. richboifexekappa 89 — 6y
0
-1. Too many comments, makes it harder to read. You can improve readability by shortening the comments or moving them outside of the code, or not having them at all. User#24403 69 — 6y
0
@incapaxian I don't quite get your point, I put all the comments so that people can read them and maybe learn what every part does and maybe learn how to do them alone. richboifexekappa 89 — 6y
0
richboyfexekapapa ill try the script when i have the time. AnotherPerson_999 28 — 6y
Ad
Log in to vote
-3
Answered by 6 years ago

You said you wanted to make it increase when you click shift, but this one increses when you click E???

anyways, here.

repeat wait() until game.Players.LocalPlayer
local player = script.Parent.Parent
local mouse = player:GetMouse()
mouse.KeyDown:connect(function(key)
    if key == "e" then
    player.Character.Humanoid.WalkSpeed.Value = 20
--any number works other than 20
end
end)

lol i hope this helped

0
bad User#23365 30 — 6y
0
mouse.KeyDown is deprecated, use UserInputService yHasteeD 1819 — 6y

Answer this question