Humanoid is not a valid member of Backpack

i couldnt find a soulution for this on google or dev forums so im asking here.

it doesnt work for the unequip by the way

local weapon = script.Parent

local equipAnim = script:FindFirstChild("WeaponEquip")
local idleAnim = script:FindFirstChild("WeaponIdle")

weapon.Equipped:Connect(function()
	local hum = script.Parent.Parent.Humanoid
	
	-- anim tracks
	local equipAnimTrack = hum:LoadAnimation(equipAnim)
	local idleAnimTrack = hum:LoadAnimation(idleAnim)
	
	-- anim playing
	equipAnimTrack:Play()
	
	idleAnimTrack:Play()
	
	Equipped = true
	
	
end)

weapon.Unequipped:Connect(function()
	
	local hum = script.Parent.Parent.Humanoid

	-- anim tracks
	local unequipAnimTrack = hum:LoadAnimation(equipAnim)
	
	-- anim playing
	unequipAnimTrack:Play()
	
	unequipAnimTrack:AdjustSpeed(-1) -- reverse



end)

and here is where the script is located:

image

any more images or code (even though i have barely) i am free to do

i am going to guess this only error only happens when the tool is unequipped. when you unequip the tool, it goes back to the backpack (and not the character) yet you have a variable trying to get the Humanoid from supposedly character (it is now inside the Player), do:

local Player = script:FindFirstAncestorOfClass("Player")
local Character = Player.Character or Player.CharacterAdded:Wait()

local Humanoid = Character:FindFirstChild("Humanoid")

also @batteryday that would just look for the humanoid inside the tool

2 Likes

You are right. I read it too fast :joy:


I think it is because when Unequip fires, the tool is already back in the Backpack.

1 Like

fastest ever solve lol

charactershorten

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.