Need help with health gui

humanoid.Health is the value

here is the module script if that helps


local TweenService = game:GetService("TweenService")
local ContextActionService = game:GetService("ContextActionService")

local humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")

function Core.Health(percentLabel, bar)
	-- Tweening
	local maxHealth = humanoid.MaxHealth
	local currentHealth = humanoid.Health

	local info = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.In)
	local size = math.clamp(currentHealth / maxHealth,  0,  1)

	local tween = TweenService:Create(bar, info, { Size = UDim2.new(size,  0,  1,  0) })

	tween:Play()

	percentLabel.Text = tostring(math.floor(size *  100)).."%"

	--//Main Functions
end

you shouldnt need a module script this should be simple with humanoid.healthchanged

Why is there a modulescript in the first place, you should just 1 simple localscript to determine the size of the ui like this for example, although it doesn’t go back to it’s original state once the humanoid dies you could just tweak it around a bit or set the reset on spawn to true.

local player = game:GetService("Players").LocalPlayer
local character = player.Character or game:GetService("Players").LocalPlayer.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

character:WaitForChild("Humanoid"):GetPropertyChangedSignal("Health"):connect(function()
	script.Parent:TweenSize(UDim2.new(humanoid.Health / humanoid.MaxHealth, 0,1,0), Enum.EasingDirection.InOut,Enum.EasingStyle.Linear,0.5,true)
	script.Parent.Parent.TextLabel.Text = "Health: " .. math.round(humanoid.Health) .. "/" .. humanoid.MaxHealth
end)

i tried reset on spawn and it doesnt work

@Roastdbacon i used a module because its not just for health its for everything with my ui

The reset on spawn only applies to my example.