Problems with loading humanoid

Ever since I started getting into scripting I never found a proper way to load the humanoid. I tried looking around and I can’t find any sources to help and sometimes they don’t work if I do find the right one.

Anyways, I need help on loading the humanoid without adding the “Wait()”. I want to know a way to not have a wait in my script for this to load or atleast not have it in the very beginning of the script.
Here is my code:

wait(1) -- I want to remove this but it'll break the whole script.
local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")

if humanoid then
      print('loaded humanoid.')
end

FYI this is a local script inside the startercharacterscripts container.

1 Like
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait() 
--[[
  # waits for the character to be created if it doesn't exist

  # once it does exist, it'll return the character meaning it's assign the 
   "character" variable the player's character
]]

local humanoid = character:WaitForChild("Humanoid")

if humanoid then
   print('loaded humanoid.')
end
3 Likes