|
| 14 Dec 2015 01:12 AM |
local player = game.Players.LocalPlayer local humanoid = player.Character.Humanoid local health = humanoid.Health local maxhealth = humanoid.MaxHealth
while true do wait(0.30) game.StarterGui.hp.TextLabel.Text=(health .. "/" .. maxhealth) end
-zachattack220 |
|
|
| Report Abuse |
|
|
|
| 14 Dec 2015 01:28 AM |
after the player variable put:
repeat wait() until player.Character |
|
|
| Report Abuse |
|
|
|
| 14 Dec 2015 01:50 AM |
@NormalNorm
Still dosnt seem to work.
-zachattack220 |
|
|
| Report Abuse |
|
|
|
| 14 Dec 2015 02:01 AM |
| By the way; I wouldn't use a while loop to display the humanoid's health/maxhealth. Used a .Changed event on the humanoid instead. It's much more efficient. |
|
|
| Report Abuse |
|
|
010011011
|
  |
| Joined: 12 Dec 2015 |
| Total Posts: 400 |
|
|
| 14 Dec 2015 02:02 AM |
Number and String concentanted? Not sure about that try to tostring(health) and tostring(maxhealth) and see how that goes!
Cheers |
|
|
| Report Abuse |
|
|
T00NAMI
|
  |
| Joined: 10 Mar 2013 |
| Total Posts: 211 |
|
|
| 14 Dec 2015 06:21 AM |
The problem is you are making changes to: game.StarterGui When players join a game, all the gui's within game.StarterGui get cloned into player.PlayerGui
So make the changes into player.PlayerGui instead. And if you have FilteringEnabled on, you need to use remote functions. But I don't think you do so don't worry about this technical detail.
Try something like this:
local Player = game.Players.LocalPlayer repeat wait() until Player and Player.Character local Humanoid = Player.Character:WaitForChild("Humanoid") local HealthGui = Player.PlayerGui:WaitForChild("hp") local HealthLabel = HealthGui:WaitForChild("TextLabel")
Humanoid.Changed:connect(function(property) if property == Health then HealthLabel.Text = Humanoid.Health.." / "..Humanoid.MaxHealth end end)
If it doesn't work, then one of the WaitForChild()'s probably couldn't find it. TIP: use prints in various places to debug your scripts. |
|
|
| Report Abuse |
|
|
|
| 14 Dec 2015 06:28 AM |
-- This is more efficient, and makes more sense.
local Player = game:GetService("Players").LocalPlayer local Humanoid = Player.CharacterAdded:wait():WaitForChild("Humanoid") local HealthLabel = Player.PlayerGui:WaitForChild("hp"):WaitForChild("TextLabel")
Humanoid.HealthChanged:connect(function(Health) HealthLabel.Text = Health.." / "..Humanoid.MaxHealth end) |
|
|
| Report Abuse |
|
|