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

Overhead Health Gui not working?

Hi, I have a Overhead health gui that allows people on the server to see the amount of health you have. I have a script named "OverheadGuiScript" which is a normal script in StarterCharacterScript and a billboard gui named 'HealthGui' in it as a child. Under the healthgui there is a frame called Background and a text label called 'Indicator'. Under Background is a frame called 'Health'. The problem is that the health bar is not going down and the indicator is not changing at all. Please help.

OverheadGuiScript:

local char = script.Parent
local humanoid = char:FindFirstChild('Humanoid')
local healthGui = script.HealthGui
healthGui.Parent = char.Head
	 
	humanoid.HealthChanged:Connect(function()
	    local healthColor = Color3.fromRGB(255,0,0):Lerp(Color3.fromRGB(85,255,0),humanoid.Health/humanoid.MaxHealth)
	local healthChange = humanoid.Health/humanoid.MaxHealth
	healthGui.Background.Health:TweenSize(UDim2.new(healthChange,0,1,0),"In","Linear",1)
	healthGui.Background.Health.BackgroundColor3 = healthColor
	healthGui.Background.Health.Indicator.Text = "Health: ".. math.floor(humanoid.Health).."/"..(humanoid.MaxHealth)
	end)

2 comments

0

How are you applying the damage to test if it's working?

0

by setting my health to 50 in the humanoid of my character

1 answer

✓ Accepted answer

No issues with the code, this works fine however the issue lies with replication of properties.

In this scenario he was editing his health from the client through studio it's properties window which will cause it not to replicate back to the server.

Server thus will not pick up any changes in the health and the code will never fire.

Solution is to switch to server mode (Home tab > Current: client) and edit the properties from there.

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