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 3 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:

local plr = game.PLayer.LocalPlayer
local uis = game:GetService("UserInputService")
local character = plr.Character or plr.CharacterAdded:Wait()
local humanoid = character.Humanoid or character:WaitForChild("Humanoid")

local shift = Enum.KeyCode.LeftShift
local Isshiftdown = uis:IskeyDown(shift)

uis.InputBegan:Connect(function(Input, gameProcessedEvent)
    if Isshiftdown then
        humanoid.Walkspeed = 25
    else
        humanoid.Walkspeed = 16
    end
end)

2 answers

Log in to vote
2
Answered by
Accoast 43
3 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 — 3y
Ad
Log in to vote
0
Answered by 3 years ago
local plr = game.PLayer.LocalPlayer
local uis = game:GetService("UserInputService")
local character = plr.Character or plr.CharacterAdded:Wait()
local humanoid = character.Humanoid or character:WaitForChild("Humanoid")

local shift = Enum.KeyCode.LeftShift
local Isshiftdown = uis:IskeyDown(shift)

uis.InputBegan:Connect(function(Input, gameProcessedEvent)
    if Isshiftdown then
        humanoid.WalkSpeed = 25
    else
        humanoid.WalkSpeed = 16 -- the error was that you misspelled it!
    end
end)

your supposed to do 'WalkSpeed' not 'Walkspeed'

Answer this question