Error : attempt index nil with humanoid line 132
it happens when u reset after the rounds end…
Error : attempt index nil with humanoid line 132
it happens when u reset after the rounds end…
You should check if the humanoid also exists
Using :WaitForChild() would help. If there is no humanoid, it will wait for it.
I was about to say that you should use :FindFirstChild() (considering that we dont know if the code is running on the loop) to check if the humanoid exists
Is it okay if i do like this…
if v.Character and v.Character:FindFirstChildOfClass("Tool") and v:FindFirstChild("Backpack") then
v.Character.Humanoid:UnequipTools()
v.Backpack:ClearAllChildren()
end
end
You’re running this code in a loop or not?
yes i run this script for a loop.
@CAROR567 and @zaydoudou
good joke guys, but
it says “attempt index nil with humanoid line 132”
so the character / whatever is not loaded, if you use FindFirstChild or WaitForChild it will give the same result
So the sript i do now will works fine?
Im telling him to add it to the if statement. Something like this
if v:FindFirstChild(“Backpack”) and v.Character:FindFirstChild(“Humanoid”) then
No its right it unequip my tools
alright i will test that if i see that my script dont work and still crash.
as i said, the character is still nil mister zaydoudou, you’re indexing it with “FindFirstChild” is just a replacement from “Attempt index nil with humanoid line 132” to “Attempt index nil with FindFirstChild line 132”
So do :WaitForChild(‘Character’)
Yes but it will take a second for the character to load so it doesn’t really matter (or you can use :WaitForChild() )
considering that the code is on loop
damn boy what if that’s a player
quick answer
local character = v.Character or v.CharacterAdded:Wait() -- with the waitforchild thing
Alright already fixed!
when i use my own script :
if v.Character and v.Character:FindFirstChildOfClass("Tool") and v:FindFirstChild("Backpack") then
v.Character.Humanoid:UnequipTools()
v.Backpack:ClearAllChildren()
end
end
but i will give solved to someone gave me idea for it.
This is just like alternative to :WaitForChild(‘Character’)
big no, waitforchild is waiting until an object exist in a parent, not a value
yes your right it still nil also if you accidentaly leave.