Humanoid is not a valid member of Model

I’m change the players WalkSpeed in a LocalScript which is in a GUI. How can I fix this problem?

I’m making a loading GUI, and I want to change the player’s WalkSpeed, for now

Here is my code:

local gui = script.Parent
local background = gui:WaitForChild("Background")
local bar = background:WaitForChild("Bar")
local filler = bar:WaitForChild("Filler")
local percentage = bar:WaitForChild("Percent")

gui.Enabled = true

local player = game.Players.LocalPlayer

player.Character.Humanoid.WalkSpeed = 0
game.Lighting.Blur.Enabled = true

player.PlayerGui.Ammo.Enabled = false
player.PlayerGui.Codes.Enabled = false
player.PlayerGui.HealthBarGui.Enabled = false
player.PlayerGui.HotbarGUI.Enabled = false
player.PlayerGui.KillAll.Enabled = false
player.PlayerGui.LeaderboardGUI.Enabled = false
player.PlayerGui.PlayerScreenStuff.Enabled = false
player.PlayerGui.ShopGui.Enabled = false
player.PlayerGui.Stamina.Enabled = false

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)


for i = 1, 100 do
	percentage.Text = i.."%"
	local formula = i/100
	filler:TweenSize(, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.1, true)
	if i == math.random(1,3) or i == math.random(31,34) or i == math.random(42,47) or i == math.random(61,74) or i == math.random(79,87) or i == math.random(91,98) then

local tween = game.TweenService:Create(gui.Fade,, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {["BackgroundTransparency"] = 0})

gui.Background.Visible = false

tween = game.TweenService:Create(gui.Fade,, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {["BackgroundTransparency"] = 1})

script.Parent.Parent.Welcome.Enabled = true

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)


– papahetfan

Please show us your code, so we could tell

Sorry, I added the script in my topic!

You’re receiving that error because the script is running in advance before the Humanoid spawns ingame.

player.Character:WaitForChild("Humanoid").WalkSpeed = 0
try to yield the script until the humanoid is found ^


With line 9, you’re assuming the character and the humanoid both exist at the time this code is executed. This is most likely never going to happen if your script runs before the player spawns.

So what do you do? You wait for the humanoid to appear.

local character = game.Players.LocalPlayer.Character
if not character then -- if our character doesn't exist yet, we wait
    character = game.Players.LocalPlayer.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
humanoid.WalkSpeed = 0

I wouldn’t recommend using loops to wait for something to happen, polling (using a time loop to wait for something to happen) is generally bad practice and more costly than using events to trigger things to happen.
I would also HIGHLY suggest that you verify the walkspeed on the server, especially when it gets changed.

1 Like

Found The Solution! Thank you for the Help!