My script isnt working

I am a very new script only starting 10 months ago i was just scripting for fun when i typed a script idk what i did wrong i put it in the player folder as a local script please help

local RunningSpeed = 30

local runService = game:GetService("RunService") 

local player = game:GetService("Players").LocalPlayer

local humanoid = player.Character:WaitForChild("Humanoid")

local maxSpeed

local runTable

local part = humanoid:WaitForChild("HumanoidRootPart")
local speed = part:GetPropertyChangedSignal("Speed")

What is the script meant to do…?

running script when you click shift makes you faster when you release it slows down

Accidentally replied to the wrong person, sorry…!

Made the sprint system for you and didn’t take long. So for this to work correctly:
Create a new local script inside of “StarterCharacterScripts”,
you can call the new local script what ever you like.

image

Then we move onto the script:
All you can do from here is, copy and paste
the the code into your newly found local script…

-- services
local userInputService = game:GetService("UserInputService")
local players = game:GetService("Players")

-- variables
local player = players.LocalPlayer
local defaultWalkspeed = player.Character.Humanoid.WalkSpeed

-- key
local keyToUseHere = Enum.KeyCode.LeftControl

-- speed
local speedAmount = 30

-- input event
userInputService.InputBegan:Connect(function(input, gameProcessed)
	if gameProcessed or userInputService.TouchEnabled then
		return
	end
	if userInputService.KeyboardEnabled and userInputService.MouseEnabled then
		if input.UserInputType == Enum.UserInputType.Keyboard and input.KeyCode == keyToUseHere then
			if player.Character.Humanoid.WalkSpeed == defaultWalkspeed then
				player.Character.Humanoid.WalkSpeed = speedAmount
			elseif player.Character.Humanoid.WalkSpeed == speedAmount then
				player.Character.Humanoid.WalkSpeed = defaultWalkspeed
			end
		end
	end
end)

If this worked then mark this post as the solution…

Why so many if statements? UserInputService has the “:IsKeyDown()” method for a reason.

while UserInputService:IsKeyDown(Enum.KeyCode.LeftShift) or UserInputService:IsKeyDown(Enum.KeyCode.RightShift) do
-- speed
end

My preferred way, I guess…
Also why use a while loop when it can sometimes
hinder on performance depending where’re you’re using it.

How about InputBegan/InputEnded, then? Haven’t used the latter event, so I don’t know.

change Speed to WalkSpeed
de loolloo