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: Create custom healthbar w/ UDim2?

Previous Thread :: Next Thread 
Nickelele is not online. Nickelele
Joined: 26 Oct 2010
Total Posts: 11550
19 Feb 2016 04:38 PM
I can pay, but i really just wanna have a script dedicated to a healthbar in my RPG.

What i really wanna see, is the UDim2 in action. So please script in the less formated way (for dumwits)



Nanatsu No Taizai
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
19 Feb 2016 04:41 PM
UDim2 in action? It's basically just calling UDim2.new().
What you need to do, is have the CURRENT HEALTH divided by the MAXIMUM HEALTH, and shape the health bar itself (the bar that moves depending on health) to that result.

Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784
Report Abuse
Agluk15 is not online. Agluk15
Joined: 13 Feb 2016
Total Posts: 193
19 Feb 2016 04:44 PM
The formula for size is Humanoid.Health / Humanoid.MaxHealth * MaximumSize.
Report Abuse
Nickelele is not online. Nickelele
Joined: 26 Oct 2010
Total Posts: 11550
19 Feb 2016 04:52 PM
I just don't get it. How does it work out??



Nanatsu No Taizai
Report Abuse
Nickelele is not online. Nickelele
Joined: 26 Oct 2010
Total Posts: 11550
19 Feb 2016 05:22 PM
:/



Nanatsu No Taizai
Report Abuse
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
19 Feb 2016 05:45 PM
Basically current health divided by max health times by the size of the health bar. (I think)
Report Abuse
Weirdraidercs35 is not online. Weirdraidercs35
Joined: 14 May 2015
Total Posts: 2275
19 Feb 2016 05:52 PM
how much will you pay ?


Report Abuse
Weirdraidercs35 is not online. Weirdraidercs35
Joined: 14 May 2015
Total Posts: 2275
19 Feb 2016 05:54 PM
you literly only need one line which is
script.Parent.Frame.Health.Frame.Size = UDim2.new(human.Health/human.MaxHealth,0,1,0)


Report Abuse
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
19 Feb 2016 06:00 PM
I made an open-source place for it.
http://www.roblox.com/games/366128708/HealthGui-Test-for-Nick
Click the three dots and then Edit (I'm sure you know how to, ahaha).
Report Abuse
Agluk15 is not online. Agluk15
Joined: 13 Feb 2016
Total Posts: 193
19 Feb 2016 06:17 PM
I will make you own later, rn I'm busy.
Report Abuse
Agluk15 is not online. Agluk15
Joined: 13 Feb 2016
Total Posts: 193
19 Feb 2016 07:14 PM
Alright, put this in a LocalScript inside of the bar you want to resize. No editing required. NOTE: MAKE THE BAR SIZE WITH SCALE FACTOR ONLY (Only for length; width can be pixels if you want).

local Player = game.Players.LocalPlayer

local Character = Player.Character or Player.CharacterAdded:wait()
local Humanoid = Character:WaitForChild("Humanoid")

local XScale = script.Parent.Size.X.Scale
local YScale = script.Parent.Size.Y.Scale
local YPixels = script.Parent.Size.Y.Offset

Humanoid.HealthChanged:connect(function()
script.Parent.Size = UDim2.new(Humanoid.Health/Humanoid.MaxHealth*XScale,0,YScale,YPixels)
end)
Report Abuse
Nickelele is not online. Nickelele
Joined: 26 Oct 2010
Total Posts: 11550
20 Feb 2016 08:32 AM
I want this to work for an NPC enemy, not a local player.



Nanatsu No Taizai
Report Abuse
Gensoki is not online. Gensoki
Joined: 15 Feb 2014
Total Posts: 1982
20 Feb 2016 08:38 AM
Same concept harness the properties of the humanoid


#code http://www.roblox.com/Schwarzesmarken-Opening-TV-Size-item?id=345656154 "Let's just say goodbye"
Report Abuse
Nickelele is not online. Nickelele
Joined: 26 Oct 2010
Total Posts: 11550
20 Feb 2016 08:41 AM
Why won't it work for me then :P



Nanatsu No Taizai
Report Abuse
Gensoki is not online. Gensoki
Joined: 15 Feb 2014
Total Posts: 1982
20 Feb 2016 08:43 AM
local NPC = script.Parent
local humanoid = NPC:WaitForChild'Humanoid'

humanoid.HealthChanged:connect(function()
--bar resize health / maxhealth
end)


#code Let's just say goodbye
Report Abuse
Nickelele is not online. Nickelele
Joined: 26 Oct 2010
Total Posts: 11550
20 Feb 2016 08:50 AM
I sorta just remade the other guy's script


local Humanoid = script.Parent.Parent.Parent.Parent.Parent.Parent.Human

local XScale = script.Parent.Size.X.Scale
local YScale = script.Parent.Size.Y.Scale
local YPixels = script.Parent.Size.Y.Offset

Humanoid.HealthChanged:connect(function()
script.Parent.Size = UDim2.new(Humanoid.Health/Humanoid.MaxHealth*XScale,0,YScale,YPixels)
end)



Nanatsu No Taizai
Report Abuse
Nickelele is not online. Nickelele
Joined: 26 Oct 2010
Total Posts: 11550
20 Feb 2016 08:51 AM
Its working now.



Nanatsu No Taizai
Report Abuse
Agluk15 is not online. Agluk15
Joined: 13 Feb 2016
Total Posts: 193
20 Feb 2016 10:30 AM
Sorry, didn't realize it was for an NPC. Glad you got it working :D
Report Abuse
Nickelele is not online. Nickelele
Joined: 26 Oct 2010
Total Posts: 11550
20 Feb 2016 10:35 AM
I'm really happy for your help Agluk! :D



Nanatsu No Taizai
Report Abuse
Agluk15 is not online. Agluk15
Joined: 13 Feb 2016
Total Posts: 193
20 Feb 2016 10:37 AM
No problem bro
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