Why cant it find the child?

Im trying to get a child, and it worked in one game, but not this one i just moved it to… Please help

local TweenService = game:GetService("TweenService")


local Script = script
local Players = game:GetService("Players")
local Character = Script.Parent
local Player = Players:GetPlayerFromCharacter(Character)
local Run = game:GetService("RunService")

local bar = Character.Head:WaitForChild("OverheadGUI"):WaitForChild("HealthBar"):WaitForChild("Bar") --It cant find this, even though after many checks, its there. 

local event = game.ReplicatedStorage.LowHealth

local info = TweenInfo.new(

	1,
	Enum.EasingStyle.Cubic

)


Player.Character.Humanoid.HealthChanged:Connect(function()
	local bar = Character.Head:WaitForChild("OverheadGUI"):WaitForChild("HealthBar"):WaitForChild("Bar")
	event:FireClient(Player, Player.Character.Humanoid.Health)

	local barheath = Player.Character.Humanoid.Health * 2


	print(barheath)

	--bar.Size = UDim2.new(0, barheath, 0, 16)
	TweenService:Create(bar, info, {Size = UDim2.new(0, barheath, 0, 16)}):Play()

	bar.ImageColor3 = Color3.new(1, 0, 0):Lerp(Color3.new(0, 1, 0), Player.Character.Humanoid.Health / 100)

end)

It is located is starter character scripts

even after checking for correct spelling, it still wont work. i have changed nothing from when it was in the previous game…

1 Like

I’m not 100% sure why this is happening but here’s a possible solution.

  1. Have it print something if it bar == nil, just to show you if it’s nil or not

  2. Have it be findfirstchild then put

if not bar then return end

  1. Make sure all the parents exist. If they don’t exist it will not find it!

If you can’t figure it out after these things I’ll think of another method