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

the Output keeps saying that humanoid isn’t part of character?

Asked by
Grazer022 128
4 years ago
local UIS = game:GetService(“UserInputService”)
local Player = game.Players.LocalPlayer
local sprinting = false
local char = Player.Character

UIS.InputBegan:Connect(function(key, gameProcessed)
      if not gameProcessed then
         if key.KeyCode == Enum.KeyCode.Ctrl then
            if sprinting == false then
                local humanoid = char.Humanoid
                humanoid.WalkSpeed = 25
                 if humanoid.Walkspeed == 25 then
                     sprinting = true
                      print(Player.Name..”is running”)
                 end
            end
       end
end)

the Output keeps saying that humanoid isn’t a part of char. pls help

2 answers

Log in to vote
0
Answered by 4 years ago

You could try doing

local humanoid = char:WaitForChild("Humanoid")

I forgot how people usually say why this happens, something because the Humanoid has not loaded in yet or something, but that should work.

Ad
Log in to vote
0
Answered by 4 years ago

better practice is to put this in your function

char = player.Character or player.CharacterAdded:wait()

Answer this question