|
| 07 Dec 2016 07:25 PM |
I'm going to disable the Core Gui, so I'm making a Gui that has money, username, the team you're currently on, and health, but my health part isn't working. (This is in a LocalScript in a ScreenGui, which is in StarterGui)
-- local plr = game.Players.LocalPlayer
while wait() do script.Parent.PrimaryInfo.Frame.Health.Text = plr.Character.Humanoid.Health.Value end --
WORKSPACE: prntscr /dgpcyk
Please help, thanks in advance!
|
|
|
| Report Abuse |
|
|
|
| 07 Dec 2016 07:26 PM |
| script.Parent.PrimaryInfo.Frame.Health.Text = plr.Character.Humanoid.Health |
|
|
| Report Abuse |
|
|
| |
|
|
| 07 Dec 2016 07:33 PM |
script.Parent.PrimaryInfo.Frame.Health.Text = tostring(plr.Character.Humanoid.Health)
?
|
|
|
| Report Abuse |
|
|
|
| 07 Dec 2016 07:34 PM |
^
Heatlh.Value
I like cake.^ |
|
|
| Report Abuse |
|
|
| |
|
|
| 07 Dec 2016 07:39 PM |
lets go see what 11 year old alvinblox says on youtube
|
|
|
| Report Abuse |
|
|
|
| 07 Dec 2016 07:40 PM |
| Sometimes LocalScripts load before the player, try to reset and see if it works. |
|
|
| Report Abuse |
|
|
| |
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 07 Dec 2016 07:42 PM |
local player = game.Players.LocalPlayer local char = player.Character
char.Humanoid.HealthChanged:connect(function(health) script.Parent.PrimaryInfo.Frame.Health.Text = health end)
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 07 Dec 2016 07:43 PM |
Just make sure the character is loaded.
|
|
|
| Report Abuse |
|
|
|
| 07 Dec 2016 07:43 PM |
local plr = game.Players.LocalPLayer local chr,human = plr.Character,plr.Character:WaitForChild'Humanoid' local healthtxt = script.Parent.PrimaryInfo.Frame.Health
healthtxt.Text = human.Maxhealth
human.HealthChanged:connect(function(health) healthtxt.Text = health end
|
|
|
| Report Abuse |
|
|
i_Ja
|
  |
| Joined: 06 Apr 2014 |
| Total Posts: 9297 |
|
|
| 07 Dec 2016 07:50 PM |
local Player = game.Players.LocalPlayer local Character = Player.CharacterAdded:wait() repeat wait() until Character:FindFirstChild("Humanoid") local Humanoid = Character.Humanoid
while wait() do script.Parent.PrimaryInfo.Frame.Health.Text = math.floor(Character.Health/Humanoid.MaxHealth) end
~Add 5k+ Posts~ {Previous Names: ContentCrown, i_Movie, SurfaceLight} |
|
|
| Report Abuse |
|
|
i_Ja
|
  |
| Joined: 06 Apr 2014 |
| Total Posts: 9297 |
|
|
| 07 Dec 2016 07:51 PM |
Humanoid.Health/Humanoid.MaxHealth** oops
~Add 5k+ Posts~ {Previous Names: ContentCrown, i_Movie, SurfaceLight} |
|
|
| Report Abuse |
|
|
|
| 07 Dec 2016 07:57 PM |
I feel like there's something else messing this up.. None of this is working...
|
|
|
| Report Abuse |
|
|
i_Ja
|
  |
| Joined: 06 Apr 2014 |
| Total Posts: 9297 |
|
|
| 07 Dec 2016 08:01 PM |
Learn how to define variables.
local Player = game.Players.LocalPlayer local PlayerGui = Player.PlayerGui
local HealthGui = PlayerGui:WaitForChild("HealthGui") local HealthFrame = HealthGui:WaitForChild("HealthFrame") local HealthStatus = HealthFrame:WaitForChild("HealthStatus")
local Character = Player.Character local Humanoid = Character.Humanoid
Humanoid.Changed:connect(function() HealthStatus:TweenPosition(UDim2.new((Humanoid.Health/Humanoid.MaxHealth),0,1,0), "Out", "Quint", 1, true) end)
~Add 5k+ Posts~ {Previous Names: ContentCrown, i_Movie, SurfaceLight} |
|
|
| Report Abuse |
|
|
i_Ja
|
  |
| Joined: 06 Apr 2014 |
| Total Posts: 9297 |
|
|
| 07 Dec 2016 08:03 PM |
You can use tweenposition too, but that's a weird health gui imo, but if you want a roblox style one, use TweenSize
~Add 5k+ Posts~ {Previous Names: ContentCrown, i_Movie, SurfaceLight} |
|
|
| Report Abuse |
|
|
|
| 07 Dec 2016 08:05 PM |
I know how to define variables, and I want a number, not bar for health.
|
|
|
| Report Abuse |
|
|
i_Ja
|
  |
| Joined: 06 Apr 2014 |
| Total Posts: 9297 |
|
|
| 07 Dec 2016 08:07 PM |
Ohhh right... Uh...
HealthStatus will be a textlabel then.
Change the Tweenposition thing to
HealthStatus.Text = math.floor(Humanoid.Health/Humanoid.MaxHealth)
If that doesn't work then I don't know what to tell ya
~Add 5k+ Posts~ {Previous Names: ContentCrown, i_Movie, SurfaceLight} |
|
|
| Report Abuse |
|
|
|
| 07 Dec 2016 08:20 PM |
I put
--- local Player = game.Players.LocalPlayer local Character = Player.CharacterAdded:wait() repeat wait() until Character:FindFirstChild("Humanoid") local Humanoid = Character.Humanoid
while wait() do Player.PlayerGui.CoreGui.PrimaryInfo.Frame.Health.Text = math.floor(Humanoid.Health/Humanoid.MaxHealth) end ---
In a separate LocalScript to see if its something else in the script messing with it, so now when my health is 100 the gui says "1", but anything less and the gui will say 0
|
|
|
| Report Abuse |
|
|
|
| 07 Dec 2016 08:21 PM |
local Player = game.Players.LocalPlayer local Character = Player.CharacterAdded:wait() repeat wait() until Character:FindFirstChild("Humanoid") local Humanoid = Character.Humanoid
while wait() do Player.PlayerGui.CoreGui.PrimaryInfo.Frame.Health.Text = Humanoid.Health end |
|
|
| Report Abuse |
|
|
|
| 07 Dec 2016 08:22 PM |
You're mistakenly putting while wait() do inside a script which is inside a StarterGui Gui
Never do that. Ever. Errors just everywhere.
|
|
|
| Report Abuse |
|
|
|
| 07 Dec 2016 08:22 PM |
| Not only errors, it's just totally inefficient and wasteful. |
|
|
| Report Abuse |
|
|
|
| 07 Dec 2016 08:26 PM |
Alright!
local Player = game.Players.LocalPlayer local Character = Player.CharacterAdded:wait() repeat wait() until Character:FindFirstChild("Humanoid") local Humanoid = Character.Humanoid
while wait() do Player.PlayerGui.CoreGui.PrimaryInfo.Frame.Health.Text = Humanoid.Health.."%" end
Works, but only when it's in a separate localgui from my other stuff for some reason.. I mean, this works, but I'd rather not have extra scripts
|
|
|
| Report Abuse |
|
|