Hello I was making my script and I had to make a variable for humanoid. This is my script
local humanoid = game.Players.LocalPlayer.Character.Humanoid
I get errors like this
Players.applebugr21.Backpack.L.1Sword.AnimationLocalScript:2: attempt to index field 'Character' (a nil value)
when I run the scrip. What is wrong with is code? Help me
Depending on some scenarios, the Character Rig may not load in before the program makes an attempt to allocate it, instead, we tell our program to yield until it does.
local Player = game:GetService("Players").LocalPlayer local Character = Player.Character or Player.CharacterAdded:Wait() local Humanoid = Character:FindFirstChild("Humanoid")
local humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")