-
What do you want to achieve? I have a base health billboard gui that its parented to PlayerGui.Billboards
-
What is the issue? when player resets the billboard destroys and never comes back
-
What solutions have you tried so far? idk how to fix it, the only solution that im thinking is disable reset button but if there is another solution please help
(MODULE SCRIPT)
local Players = game:GetService("Players")
local health = {}
function health.Setup(model, screenGui)
local newHealthBar = script.HealthGui:Clone()
newHealthBar.Adornee = model:WaitForChild("Head")
newHealthBar.Parent = Players.LocalPlayer.PlayerGui:WaitForChild("Billboards")
newHealthBar.ResetOnSpawn = false
if model.Name == "Base" then
newHealthBar.MaxDistance = 70
newHealthBar.ResetOnSpawn = false
newHealthBar.Size = UDim2.new(0, 200, 0, 50)
else
newHealthBar.ResetOnSpawn = false
newHealthBar.MaxDistance = 35
newHealthBar.Size = UDim2.new(0, 150, 0, 40)
end
health.UpdateHealth(newHealthBar, model)
if screenGui then
health.UpdateHealth(screenGui, model)
end
model.Humanoid.HealthChanged:Connect(function()
health.UpdateHealth(newHealthBar, model)
if screenGui then
health.UpdateHealth(screenGui, model)
end
end)
end
function health.UpdateHealth(gui, model)
local humanoid = model:WaitForChild("Humanoid")
if humanoid and gui then
local percent = humanoid.Health / humanoid.MaxHealth
gui.CurrentHealth.BackGround.Size = UDim2.new(math.max(percent, 0), -0.5, 1, 0)
if humanoid.Health <= 0 then
if model.Name == "Base" then
gui.Title.Text = humanoid.Health .. "/" .. humanoid.MaxHealth
task.wait(0.5)
gui:Destroy()
end
else
gui.Title.Text = humanoid.Health .. "/" .. humanoid.MaxHealth
end
end
end
return health