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: How come this does not work // Health bar issues

Previous Thread :: Next Thread 
TheNewChicken is not online. TheNewChicken
Joined: 18 Mar 2015
Total Posts: 1997
25 May 2015 05:03 PM
Not sure if i should use the same thread for a diff issue on same subject..?

heres my code, anyways it goes out of the whole screen. I want maybe 1/10 of that size.

Heres my code:

local Players = game:GetService("Players")

repeat wait() until Players.LocalPlayer and Players.LocalPlayer.Character

local Humanoid = Players.LocalPlayer.Character:WaitForChild("Humanoid")

local HealthFrame = script.Parent:WaitForChild("HealthFrame")
local HealthLabel = script.Parent:WaitForChild("HealthAmountLabel")

Humanoid.HealthChanged:connect(function()
HealthLabel.Text = "Health: "..math.ceil(Humanoid.Health).."/"..math.ceil(Humanoid.MaxHealth)
HealthFrame.Size = UDim2.new(Humanoid.Health/Humanoid.MaxHealth,0,.05,0)
HealthFrame.Position = UDim2.new(.5,-HealthFrame.AbsoluteSize.X/2,.925,0)
end)
Report Abuse
RedX8 is not online. RedX8
Joined: 02 Jun 2010
Total Posts: 839
25 May 2015 05:06 PM
So it seems you're looking for the formula to get the percentage of the Health, and MaxHealth? This will make it fit in a specified size, and still be dynamic.
Report Abuse
TheNewChicken is not online. TheNewChicken
Joined: 18 Mar 2015
Total Posts: 1997
25 May 2015 05:07 PM
Uh i didnt quite understand that. Basically i want to scale the size it sets it to to that /10.

FOr some reason its fitting the whole screen o3o.
Report Abuse
RedX8 is not online. RedX8
Joined: 02 Jun 2010
Total Posts: 839
25 May 2015 05:08 PM
(Health / MaxHealth) * SpecifiedSize
Report Abuse
RedX8 is not online. RedX8
Joined: 02 Jun 2010
Total Posts: 839
25 May 2015 05:12 PM
Example:
(25 / 100) = 0.25
0.25 * (200 pixels in size) = 50

So 50 is 1/4 of the size of 200 pixels.
Report Abuse
TheNewChicken is not online. TheNewChicken
Joined: 18 Mar 2015
Total Posts: 1997
25 May 2015 05:17 PM
i figured it out.

It was the X Size of the gui, so *.2
Report Abuse
RedX8 is not online. RedX8
Joined: 02 Jun 2010
Total Posts: 839
25 May 2015 05:21 PM
Yes, the X Coordinate you want to change, but I would suggest not using .2 as your size in pixels, unless i'm mistaken, and the size is not in pixels, but in units.
Report Abuse
TheNewChicken is not online. TheNewChicken
Joined: 18 Mar 2015
Total Posts: 1997
25 May 2015 05:22 PM
Im using the left side.
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