Can't found Humanoid

So I have a script that is in the tool in the starter pack, it is a LOCAL SCRIPT. Here is the code of the script… The problem is that I can’t find a humanoid. Just in the output, nothing is written.

local players = game:GetService("Players")

local player = players.LocalPlayer
local character = player.Character or script.Parent.Parent.Parent
local humanoid = character:WaitForChild("Humanoid")

try this:

local tool = --local the tool

tool.Equipped:Connect(function()
       local Humanoid = script.Parent.Parent.Parent:FindFirstChild("Humanoid") --If the script is inside the handle this should work.
       if Humanoid then
             print("Humanoid exists!")
       else
             print("Nothing...")
       end
end)

It’s my full script:

local rp = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")

local player = players.LocalPlayer
local character = player.Character or script.Parent.Parent.Parent
local humanoid = character:WaitForChild("Humanoid")

print(humanoid)

local tool = script.Parent
local equipped = false
local event = rp:WaitForChild("Combat")
local Animations = rp:WaitForChild("Animations")



tool.RequiresHandle = false

script.Parent.Equipped:Connect(function()
	equipped = true
	print(equipped)
end)

script.Parent.Unequipped:Connect(function()
	equipped = false
	print(equipped)
end)
1 Like

so for the local character, I personally tend to use

local character = player.Character or player.CharacterAdded:Wait()

so sometimes if the game could not detect the player.Character due to loading proccess, it can wait until the character is loaded and find it, and maybe get rid of the script.parent.parent.parent thingy

use player.Character or player.CharacterAdded:Wait() instead

you can also add:

local character = player.Character or player.CharacterAdded:Wait()

not the script.Parent because the localscript will run in the backpack as you don’t start with it equipped

no nothing changed) Maybe I have a problem with HUMANOID

oh yes you’re right, i’ll fix it

do you have “Combat” and “Animations” in your ReplicatedStorage

Yes I also figured out how to fix my script I removed script.Parent.Parent.Parent

2 Likes

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