So basically I'm trying to make a short speed boost when you press shift but whenever I try the script it keeps saying Walkspeed is not a valid member of Humanoid can somebody review this code for me please, I suck at scripting and I'm like 2 days into it so don't criticize me too hard ;p
uif = game:GetService("UserInputService") uif.InputBegan:connect(function(imput) if imput.KeyCode == Enum.KeyCode.LeftShift then local plr = game.Players.LocalPlayer local char = script.Parent.Humanoid char.WalkSpeed = 25 wait(3) local char = script.Parent.Humanoid char.Walkspeed = 16 end end)
I put a explanation by every error below for you to fix :) Mostly just made small mistakes.
uif = game:GetService("UserInputService") uif.InputBegan:connect(function(imput) ---- :connect deprecated use :Connect if imput.KeyCode == Enum.KeyCode.LeftShift then local plr = game.Players.LocalPlayer local char = script.Parent.Humanoid char.WalkSpeed = 25 wait(3) ---------------------No Need---------------------------------- local char = script.Parent.Humanoid -------------------------------------------------------------------- char.Walkspeed = 16 ----- WalkSpeed not Walkspeed end end)
On Line 13 It Is Spelled "Walkspeed" When The Acutal Propety Is Called "WalkSpeed" With A Capital S. Its Okay If You Forget Something Like That We Were All New At One Point. From Now On Always Look At The Punctuation And Spelling. You Should Also Look At Scripting Tutorial Such As AlvinBlox Or Peasfactory Before You Start Making A Game.
You can say local char =
twice but u don't need too. Also in the near future :connect()
will not work. Use :Connect()
and use WalkSpeed
not Walkspeed
. I have changed local char
to my liking btw not much diffrent
uif = game:GetService("UserInputService") local player = game.Players.LocalPlayer local char = player.Character.Humanoid uif.InputBegan:Connect(function(imput) if imput.KeyCode == Enum.KeyCode.LeftShift then char.WalkSpeed = 25 wait(3) char.WalkSpeed = 16 end end)
thx for reading
Hey,
Assuming this script is located in the players character(which is located in the workspace), you only made one small error.
That small error? Capitalization! On line 13, it should be WalkSpeed and not Walkspeed.
Furthermore, :connect is now depricated and :Connect should be used instead.
Cheers.
uif = game:GetService("UserInputService") uif.InputBegan:connect(function(imput) if imput.KeyCode == Enum.KeyCode.LeftShift then local plr = game.Players.LocalPlayer local char = script.Parent.Humanoid char.WalkSpeed = 25 wait(3) char.WalkSpeed = 16 end end)
EDIT: Also, as others have said, you do not need to define char twice, once is sufficient.
You spelt WalkSpeed wrong, Speed has a Captial S. Also consider using :IsKeyDown()
for a Shift Boost
UserInputService.InputBegan:Connect(function() if (UserInputService:IsKeyDown(Enum.KeyCode.LeftShift)) then --// Whatever happens here end end)