Humanoid Walkspeed won't change?

The Walkspeed of the LocalPlayer won’t change.

I also get this error: ReplicatedFirst.LoadingScript:6: attempt to index nil with 'Humanoid'

The walkspeed is supposed to change to 0, and then when the GUI finishes loading, it is supposed to go back to normal.

Code:

-- Loading Script --

local gui = script:WaitForChild("LoadingGui")
local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character.Humanoid

gui.Parent = player.PlayerGui

gui.LoadingBlur.Parent = game.Lighting

script.Parent:RemoveDefaultLoadingScreen()


repeat
	wait(.5)
until game:IsLoaded()
wait(5)


humanoid.WalkSpeed = 0


gui.Background:TweenPosition(UDim2.new(0,0,-1.5,0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad,1)

wait(1)

repeat wait()
	game.Lighting.LoadingBlur.Size = game.Lighting.LoadingBlur.Size - 1.5
until game.Lighting.LoadingBlur.Size <= 0

humanoid.Walkspeed = 16

gui:Destroy()

If anyone has any tips, it would be greatly appreciated!

replace line 6 with

local humanoid = character:WaitForChild("Humanoid")

This part is causing the problem, so modify it like this:

local player = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

That was my first try but then I get the error: ReplicatedFirst.LoadingScript:6: attempt to index nil with 'WaitForChild'

its :WaitForChild not .WaitForChild
Also in line 5, to get the character object consistently, do

local character = player.Character or player.CharacterAdded:Wait()

You can do the same for the player object as @hasoco has written, but often you won’t need to.

When the Walkspeed is supposed to be changed back to 16, I get this error: Walkspeed is not a valid member of Humanoid "Workspace.FailedTypo.Humanoid"

1 Like

Its WalkSpeed not Walkspeed… grammar error

1 Like

Thank you for the help! Didn’t see the lowecase lol

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.