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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 26 Oct 2010 |
| Total Posts: 11550 |
|
| |
|
|
| 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 |
|
|
| |
|
|
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 26 Oct 2010 |
| Total Posts: 11550 |
|
|
| 20 Feb 2016 08:51 AM |
Its working now.
Nanatsu No Taizai |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| Joined: 13 Feb 2016 |
| Total Posts: 193 |
|
| |
|