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

Why doesn't my character's walk speed change in localscript?

Asked by 4 years ago

I am trying to make a shift to sprint script, I put a localscript in the starter pack that on key shift down walk speed should be 25 while key shift up walkspeed should be 16.

LocalScript:

01local plr = game.PLayer.LocalPlayer
02local uis = game:GetService("UserInputService")
03local character = plr.Character or plr.CharacterAdded:Wait()
04local humanoid = character.Humanoid or character:WaitForChild("Humanoid")
05 
06local shift = Enum.KeyCode.LeftShift
07local Isshiftdown = uis:IskeyDown(shift)
08 
09uis.InputBegan:Connect(function(Input, gameProcessedEvent)
10    if Isshiftdown then
11        humanoid.Walkspeed = 25
12    else
13        humanoid.Walkspeed = 16
14    end
15end)

2 answers

Log in to vote
2
Answered by
Accoast 43
4 years ago

Please provide code with your answers. Simply posting an explanation does not help someone new to programming understand how to implement a concept programatically.

Change WalkSpeed not Walkspeed.

0
Sorry, I am still a beginner NathanBlox_Studios 212 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
01local plr = game.PLayer.LocalPlayer
02local uis = game:GetService("UserInputService")
03local character = plr.Character or plr.CharacterAdded:Wait()
04local humanoid = character.Humanoid or character:WaitForChild("Humanoid")
05 
06local shift = Enum.KeyCode.LeftShift
07local Isshiftdown = uis:IskeyDown(shift)
08 
09uis.InputBegan:Connect(function(Input, gameProcessedEvent)
10    if Isshiftdown then
11        humanoid.WalkSpeed = 25
12    else
13        humanoid.WalkSpeed = 16 -- the error was that you misspelled it!
14    end
15end)

your supposed to do 'WalkSpeed' not 'Walkspeed'

Answer this question