2DWorlds Forums
I made a Health UI... But... - Printable Version

+- 2DWorlds Forums (http://2dworlds.buildism.net/forum)
+-- Forum: 2DWorlds (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=4)
+--- Forum: Help (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=21)
+--- Thread: I made a Health UI... But... (/showthread.php?tid=5332)



I made a Health UI... But... - AK-47 - 06-03-2011

1.) I don't know how to make it so that the script together with the UI will go into the PlayerUI once it enters the game.

2.) Once the player dies, the health bar will stay red. I need it so that it will run again once the player respawns.


RE: I made a Health UI... But... - Kieron - 06-03-2011

Make it trace the players health, here's a bit of code to help you:
[lua]
--Code above
if player.Health >= 25 then --Assuming you already have the player sorted out
HealthBar.Color = Color(205,25,88) --Assuming the healthbar is one piece.
else
HealthBar.Color = Color(62,190,116)
--Code below
[/lua]


RE: I made a Health UI... But... - AK-47 - 06-03-2011

No... I don't need changing colors. I already have coded it into the script so that it tooltips the player's current health.


RE: I made a Health UI... But... - Kieron - 06-03-2011

(06-03-2011, 04:09 PM)AK-47 Wrote: No... I don't need changing colors. I already have coded it into the script so that it tooltips the player's current health.

Yeah, I made it so it changes back once you die.

Maybe this would work?

[lua]
--Code
if player.Health = 0 then
HealthBar.Color = Color(green) --Replace green with the RGB.
--Code
[/lua]


RE: I made a Health UI... But... - Duck - 06-03-2011

I could give you it in roblox lua, but I can't be bothered to translate.

Assuming the script is in the UI:

[lua]-- Put UI in game.Storage

game.Storage.UI = a
Muffinz(Player)
a.Parent = Player.UI
a.script.Enabled = true (THis will activate the script below)
end

game.Players.PlayerAdded:connect(Muffinz)
[/lua]

As for the resetting, put another script in the UI with this in it :

[lua] while script.Parent.Parent.Parent.Name == Players do
wait (0.1)
if script.Parent.Parent.Character.Health > 1 then
--Reset Gui
end
end
[/lua]