Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is my health bar covering the text?

My health bar functions correctly except for the fact that the bar covers the text. Where did I go wrong in the code?

Low Health: http://prnt.sc/evsfg5

After some regeneration: http://prnt.sc/evsfkq

Code:

local info_holder = script.Parent:WaitForChild("Info_Holder")
local health = info_holder:WaitForChild("Health")

local old_health = humanoid.Health
local old_maxhealth = humanoid.MaxHealth

function update_health()
	health:TweenPosition(UDim2.new((-((humanoid.MaxHealth-humanoid.Health)%humanoid.MaxHealth)/humanoid.MaxHealth), 0, health.Position.Y.Scale, 0), "Out", "Quad", 0.25, true)
	info_holder.Health_Amount.Text = math.floor(humanoid.Health+0.5) .. " / " .. math.floor(humanoid.MaxHealth+0.5)
		if(old_health > humanoid.Health and old_maxhealth == humanoid.MaxHealth) then
		old_health = humanoid.Health
		blood_effect()
		end
	old_health = humanoid.Health
	old_maxhealth = humanoid.MaxHealth
end

2 comments

0

Try fiddling with the Text's Z-Index to make it above everything.

0

Thanks

1 answer

✓ Accepted answer

Set the TextLabel's ZIndex higher than the ZIndex of the health bar.

1 comment

0

Thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.