I am making a script but need Animator and for some reason it can’t find it, here is the error and output:
local player = game.Players.LocalPlayer
local character = player.Character
local animator = character.Humanoid:WaitForChild("Animator")
local shotEvent = replicatedStorage.Remotes:WaitForChild("shotEvent")
I think it’s because the character is not fully loaded
try this
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local animator = character.Humanoid:WaitForChild("Animator")
local shotEvent = replicatedStorage.Remotes:WaitForChild("shotEvent")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local animator = character.Humanoid:FindFirstChildOfClass("Animator")
local shotEvent = replicatedStorage.Remotes:WaitForChild("shotEvent")
That should work!
Of course, you can still use Humanoid:LoadAnimation(), however, that’s a last resort if Animator still can’t be found. It may also be a backend problem with the code you’re using, so keep that in mind aswell!
Using a loop for the character is actually not a solution, but instead more work that isn’t needed. In addition, I recommend you use task.wait() instead of wait(), due to it being a more standardized wait nowadays.
Also, please mark someone solution to help the SEO.