My script doesnt work. Ive been trying to make a script for the players to press shift if they want to run faster! But it doesnt work. Have I made a mistake in the script or what is it?
Something like this would work, but you should re-edit your question and give code.
--in a local script --in startercharacterscripts local userInputService = game:GetService("UserInputService") local character = script.Parent local humanoid = character:WaitForChild("Humanoid") --get the speeds loca RUNSPEED = 25 local DEFAULTSPEED = humanoid.WalkSpeed --if they press shift userInputService.InputBegan:Connect(function(keyPressed) if keyPressd.KeyCode = Enum.KeyCode.LeftShift then humanoid.WalkSpeed = RUNSPEED end end) --when they let go of shift userInputService.InputEnded:Connect(function(keyPressed) if keyPressed.KeyCode = Enum.KeyCode.LeftShift then humanoid.WalkSpeed = DEFAULTSPEED end end)
So it seems you want to make a sprinting script ey? well I'll help you out. P.S. Im not too sure on how to make it work when you hold it down, So im doing my best.
now First you create two local scripts and put them into StarterPlayer>StarterCharacterScripts.
Now, Name the first one anything you like and name the second one anything too. (But I don't recommend putting spaces in the Name)
Now you put the second script onto the First one making the Second local script the child of the first one.
This is the First Scripts code.
local UIS = game:GetService("UserInputService") local WalkSpeed = game.Players.LocalPlayer.Character.Humanoid.WalkSpeed local SecondScript = script.(Second Script Name) UIS.InputBegan:Connect(function(input) local Pressed = input.KeyCode if Pressed == Enum.KeyCode.LeftShift then WalkSpeed = 30 --Add any number on what speed you want. script.Disabled = true SecondScript.Disabled = false end end)
And this one is the Second script code.
local UIS = game:GetService("UserInputService") local WalkSpeed = game.Players.LocalPlayer.Character.Humanoid.WalkSpeed local FirstScript = script.Parent UIS.InputBegan:Connect(function(input) local Pressed = input.KeyCode if Pressed == Enum.KeyCode.LeftShift then WalkSpeed = 30 --Speed number thing. script.Disabled = true FirstScript.Disabled = false end end)
You can just copy and paste the scripts above.
Hope that this works for you. Toodles.
(They have to be LocalScripts and/or in StarterPlayer>StarterCharacterScripts, else this would not work)