Why does this work once?

I’m so confused how such a simple bug is holding me back…

When the player resets it drains the frame, and when player spawns back then it doesn’t register no matter what

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()

local ts = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(.6)

char:WaitForChild("Humanoid").Changed:Connect(function()
	print("changed to: "..char:WaitForChild("Humanoid").Health)
	local tween = ts:Create(script.Parent, tweenInfo, {Size = UDim2.new(char:WaitForChild("Humanoid").Health / 100,0, 1,0)}):Play()
end)

Doesn’t even print btw

Does the GUI that contains this script has ResetOnSpawn set to false?

Yeah it does, it would be stupid turning it back on since its a “Main” gui.

There are a number of small issues in your code:

  1. You set tween to be nothing since :Play() doesn’t return anything
  2. .Changed looks for anything change, use HealthChanged instead
  3. No reason to do :WaitForHumanoid three times.
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()

local ts = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(.6)
local Humanoid	= char:WaitForChild("Humanoid")	:: Humanoid 


Humanoid.HealthChanged:Connect(function(newHealth:number)
	print("changed to: "..newHealth)
	ts:Create(script.Parent, tweenInfo, {Size = UDim2.fromScale(newHealth / 100,1)}):Play()
end)ype or paste code here

Yeah they are there because I tried debugging them myself before.
Ur code made no diff since its basically my original code

a simple fix would be moving the LocalScript into StarterCharacterScripts and getting your health bar from there

and if you don’t have ResetOnSpawn enabled on your Gui then you’d have to reset the health bar manually when the player respawns

(assuming this is a script for a health bar)

The player gets a new humanoid when they respawn which makes the old humanoid connection obsolete. So you need to create a new connection to the new humanoid when the player respawns