generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Custom Health Gui Not Working

Previous Thread :: Next Thread 
iLordOfAviation is online. iLordOfAviation
Joined: 23 Mar 2012
Total Posts: 1325
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
veryveryveryhidden is online. veryveryveryhidden
Joined: 16 Dec 2012
Total Posts: 486
07 Dec 2016 07:26 PM
script.Parent.PrimaryInfo.Frame.Health.Text = plr.Character.Humanoid.Health
Report Abuse
iLordOfAviation is online. iLordOfAviation
Joined: 23 Mar 2012
Total Posts: 1325
07 Dec 2016 07:28 PM
Didn't work ^


Report Abuse
veryveryveryhidden is online. veryveryveryhidden
Joined: 16 Dec 2012
Total Posts: 486
07 Dec 2016 07:33 PM
script.Parent.PrimaryInfo.Frame.Health.Text = tostring(plr.Character.Humanoid.Health)

?
Report Abuse
LilMcManiac is not online. LilMcManiac
Joined: 31 Oct 2011
Total Posts: 2812
07 Dec 2016 07:34 PM
^

Heatlh.Value


I like cake.^
Report Abuse
iLordOfAviation is online. iLordOfAviation
Joined: 23 Mar 2012
Total Posts: 1325
07 Dec 2016 07:38 PM
Still isn't working


Report Abuse
iLordOfAviation is online. iLordOfAviation
Joined: 23 Mar 2012
Total Posts: 1325
07 Dec 2016 07:39 PM
lets go see what 11 year old alvinblox says on youtube


Report Abuse
veryveryveryhidden is online. veryveryveryhidden
Joined: 16 Dec 2012
Total Posts: 486
07 Dec 2016 07:40 PM
Sometimes LocalScripts load before the player, try to reset and see if it works.
Report Abuse
iLordOfAviation is online. iLordOfAviation
Joined: 23 Mar 2012
Total Posts: 1325
07 Dec 2016 07:42 PM
Didn't work ^


Report Abuse
Soybeen is not online. 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 is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
07 Dec 2016 07:43 PM
Just make sure the character is loaded.


Report Abuse
FlamedSkull is not online. FlamedSkull
Joined: 23 May 2009
Total Posts: 1379
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 is not online. 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 is not online. 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
iLordOfAviation is online. iLordOfAviation
Joined: 23 Mar 2012
Total Posts: 1325
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 is not online. 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 is not online. 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
iLordOfAviation is online. iLordOfAviation
Joined: 23 Mar 2012
Total Posts: 1325
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 is not online. 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
iLordOfAviation is online. iLordOfAviation
Joined: 23 Mar 2012
Total Posts: 1325
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
veryveryveryhidden is online. veryveryveryhidden
Joined: 16 Dec 2012
Total Posts: 486
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
FlamedSkull is not online. FlamedSkull
Joined: 23 May 2009
Total Posts: 1379
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
veryveryveryhidden is online. veryveryveryhidden
Joined: 16 Dec 2012
Total Posts: 486
07 Dec 2016 08:22 PM
Not only errors, it's just totally inefficient and wasteful.
Report Abuse
iLordOfAviation is online. iLordOfAviation
Joined: 23 Mar 2012
Total Posts: 1325
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image