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
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.
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