Hello, I’m trying to fix this issue where after the boss dies and when you respawn it the health bar won’t follow along the new boss that has respawned.
How can I make the health bar track the health of the new enemy after it has spawned in?
I thought of using Remote Events, but I can’t think of what to do here.
HealthBar LocalScript:
local HPBar = script.Parent
local HPText = HPBar.Parent.TextLabel
local RepStorage = game:GetService("ReplicatedStorage")
local Boss = workspace:WaitForChild("SunGuy")
HPText.Text = tostring(Boss.Humanoid.Health).."/"..tostring(Boss.Humanoid.MaxHealth)
Boss.Humanoid.HealthChanged:Connect(function(health)
local Health = math.floor(health)
HPBar:TweenSize(UDim2.new(Health/Boss.Humanoid.MaxHealth,0,1,0),Enum.EasingDirection.In,Enum.EasingStyle.Linear,1,true)
HPText.Text = tostring(Boss.Humanoid.Health).."/"..tostring(Boss.Humanoid.MaxHealth)
--HealthBar.Size = UDim2.new(Health/Boss.Humanoid.MaxHealth,0,1,0)
end)