Tool script not recognising Humanoid?

The part of my script that is causing a problem is this.

Sometimes after respawn this script will yield an error stating:

Even though the Humanoid is gotten via (WaitForChild) and I repeat wait until the Humanoid is loaded. It still gives me this error when it tries to load the animations for my tool. :confused:

Try adding this at the top of your script to make sure that the character is in the workspace

while char.Parent == nil do
1 Like

Thanks something like that worked I dont know why I didnt think of that before

Does it matter at all? It helped to solve this problem

1 Like

It is matter. Instead of copy and pasting the code from someone else on the forum you should give them a credit and send a link to the threads solution. It’s practically more professional and more secure. Thanks for your understanding.

(@Raretendoblox) What’s to say he didn’t make it himself. It’s a universal script, not just one person.

I agree @CheeseRespect2019 its 3 lines of really common code, and @ArticGamerTV your not even sure he got that bit from Gamer101’s post. Stop arguing about these small details. @Raretendoblox thanks for your help :smiley:

@CheeseRespect2019 He did created it, he was the first reply on the topic. There are slightly more ways to fix that problem and also as you called this script “universal script”. @Legenderox He litterally took the same variables names and everything. Coincidence? I think not. I am not even close to arguing with him, I am literally teaching him how to correctly use forums. Thanks to both of you for your understanding.

No he didn’t though. You can’t prove it. Simple code, OK?

Isn’t :wait() deprecated in favor of :Wait()?

I thought it was lowercase no?

Yep, it is, actually
30 characters

Something is wrong. When I use that bit of code you sent in my script. If I respawn it just ends up waiting for ever even after the character is fully loaded.

Tools run their LocalScripts immediately after they are enabled (happens after game.Loaded fires). Unfortunately, this also means that you’re experiencing the issue where Humanoid doesn’t necessarily exist as in when CharacterAdded fires.

I don’t remember the exact process for guarding against this when needing the Humanoid as an upvalue but it requires waiting for tons of signals to fire. The new character sound script has the code for this if you need it.

The best way to get around this is to load your animations from the Equip method and make sure to only do it once.

1 Like

I tried that too, but the script ended up refferring to the wrong characer everytime it reset and I had to manually set all the values again after every death.

I Shouldnt bump a thread that is over a week old but...

This is something similar to what @Raretendoblox has said.

character = player.Character
if not character or not character.Parent then
	character = player.CharacterAdded:Wait()