Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

Change WalkSpeed not Walkspeed.

1 comment

0

Sorry, I am still a beginner

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'

This discussion is preserved as it was. New answers, comments, and votes are closed.