Humanoid is not a valid member of model

So i’ve made a script for a bat walk, but it’s creating an error here.
local Humanoid = game.Players.LocalPlayer.Character.Humanoid
“Humanoid is not a valid member of Model”

local walking = false
local plr = game.Players.LocalPlayer
local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local Humanoid = game.Players.LocalPlayer.Character.Humanoid
local tool = script.Parent -- Make sure the local script is inside of the tool.
local equipped = false
local Animation = script:WaitForChild("Run") -- Place animation inside of script.
local BatIdle = script:WaitForChild("BatIdle")
local Animation2 = script:WaitForChild("Run2") -- Place animation inside of script.
local Animation3 = script:WaitForChild("Run3") -- Place animation inside of script.
local Animation4 = script:WaitForChild("Run4") -- Place animation inside of script.
local runtrack = Humanoid:LoadAnimation(Animation)
local runtrack2 = Humanoid:LoadAnimation(BatIdle)
local runtrack3 = Humanoid:LoadAnimation(Animation2)
local runtrack4 = Humanoid:LoadAnimation(Animation3)
local runtrack5 = Humanoid:LoadAnimation(Animation4)

tool.Equipped:Connect(function()
	equipped = true
runtrack2:Play()	
end)
tool.Unequipped:Connect(function()
	equipped = false
runtrack2:Stop()
	print(equipped)
end)
game:GetService("UserInputService").InputBegan:Connect(function(keyPressed, gameProcessed)
	if gameProcessed then return end
	if not equipped then return end
	if keyPressed.KeyCode == Enum.KeyCode.W then
game.ReplicatedStorage.ConnectM6D:FireServer()	
		runtrack:Play()
		repeat
		wait()
			until not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.W)
		runtrack:Stop()
		else game:GetService("UserInputService").InputBegan:Connect(function(keyPressed, gameProcessed)
	if gameProcessed then return end
	if not equipped then return end
	if keyPressed.KeyCode == Enum.KeyCode.A then
game.ReplicatedStorage.ConnectM6D:FireServer()	
		runtrack3:Play()
		repeat
		wait()
			until not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.A)
		runtrack3:Stop()
				
				
			else game:GetService("UserInputService").InputBegan:Connect(function(keyPressed, gameProcessed)
	if gameProcessed then return end
	if not equipped then return end
	if keyPressed.KeyCode == Enum.KeyCode.S then
game.ReplicatedStorage.ConnectM6D:FireServer()	
		runtrack4:Play()
		repeat
		wait()
			until not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.S)
		runtrack4:Stop()
					else
game:GetService("UserInputService").InputBegan:Connect(function(keyPressed, gameProcessed)
	if gameProcessed then return end
	if not equipped then return end
	if keyPressed.KeyCode == Enum.KeyCode.D then
game.ReplicatedStorage.ConnectM6D:FireServer()	
		runtrack5:Play()
		repeat
		wait()
			until not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.D)
		runtrack5:Stop()
					end
end)
	end
end)
	end
end)
	end
end)

why dont do char.Humanoid? then game.Players

1 Like

I did try char.Humanoid before

are you using a custom model?
[]

The bat is a meshpart yeah

character limit

your character would need a every thing that a normal player would have. so head uppertorso, lowertorso and so on. Then add a humanoid to the model your using

What do you mean…? I just need to load the animation

local Humanoid = game.Players.LocalPlayer.Character.Humanoid
local runtrack = Humanoid:LoadAnimation(Animation)
local runtrack2 = Humanoid:LoadAnimation(BatIdle)
local runtrack3 = Humanoid:LoadAnimation(Animation2)
local runtrack4 = Humanoid:LoadAnimation(Animation3)
local runtrack5 = Humanoid:LoadAnimation(Animation4)

It was working fine before, and it sometime broke. Now it just doesnt work at all

Have you tried waiting for the “Humanoid” to load in?

local Humanoid = plr.Character:WaitForChild("Humanoid")

Also you can use a print to debug if humanoid exists by using ClassName.

print(Humanoid.ClassName) -- Should print humanoid

3 Likes