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: Help!

Previous Thread :: Next Thread 
Robobloxguy10 is not online. Robobloxguy10
Joined: 06 Sep 2012
Total Posts: 526
28 Jun 2016 05:39 PM
I'm trying to make an HP ScreenGui for players. I'm trying to make it so when the health goes down, it go back up. The green health bar extends far beyond the the screen by x axis whenever the health is changed, which is not what I wanted. Please help me fix this.

Script:

local Figure = game.Players.LocalPlayer.Character
local Humanoid = Figure.Humanoid
local Gui = script.Parent
local regening = false

-----------------
--Fire Function--
-----------------

function regenHealth()
Gui.Size = UDim2.new((Humanoid.Health / Humanoid.MaxHealth),0,0.014,0)
if regening then return end
regening = true

while Humanoid.Health < Humanoid.MaxHealth do
local s = wait(1)
local health = Humanoid.Health
if health > 0 and health < Humanoid.MaxHealth then
local newHealthDelta = 0.01 * s * Humanoid.MaxHealth
health = health + newHealthDelta
Humanoid.Health = math.min(health,Humanoid.MaxHealth)
end
end

if Humanoid.Health > Humanoid.MaxHealth then
Humanoid.Health = Humanoid.MaxHealth
end

regening = false
Gui.Size = UDim2.new((Humanoid.Health / Humanoid.MaxHealth),0,0.014,0)
end

Humanoid.HealthChanged:connect(regenHealth)

while true do
wait()
script.Converter.Value = Humanoid.Health
script.Parent.Parent.HP.Text = "["..Figure.Name.."] ["..script.Converter.Value.."/"..Humanoid.MaxHealth.."]"
end
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
28 Jun 2016 05:42 PM
The default character rig already comes with health regeneration. If I were you I'd edit that. Just have the gui listen to the Humanoid's changing health value. It's generally a bad idea to manipulate stuff like health from the client anyway.
Report Abuse
Robobloxguy10 is not online. Robobloxguy10
Joined: 06 Sep 2012
Total Posts: 526
28 Jun 2016 05:44 PM
Never mind. Forget the part where I said it makes the health regen. The bar still extends beyond the screen when changed though.
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
28 Jun 2016 05:46 PM
Well here's how I do it:

Make a container, and put a filler in it, Filler Size : {1, 0, 1, 0}. Container will be the size of the entire bar.

Every time the health changes, Size would be {health/maxhealth, 0, 1, 0}.

You can also change the color of the filler if you want as health gets lower or higher.
Report Abuse
Robobloxguy10 is not online. Robobloxguy10
Joined: 06 Sep 2012
Total Posts: 526
28 Jun 2016 05:51 PM
Is container maxhealth, and filler health?
Report Abuse
Robobloxguy10 is not online. Robobloxguy10
Joined: 06 Sep 2012
Total Posts: 526
28 Jun 2016 08:39 PM
Bump
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
28 Jun 2016 08:41 PM
Yes they are.

Container is whatever size you want.

Filler is the {0, health/max, 0, 0}


"Tell me and I forget. Teach me and I remember. Involve me and I learn." - Benjamin Franklin
Report Abuse
Robobloxguy10 is not online. Robobloxguy10
Joined: 06 Sep 2012
Total Posts: 526
28 Jun 2016 09:49 PM
Would this work?

local Gui = script.Parent --ImageLabel
local Player = game.Players.LocalPlayer
local Character = Player.Character.Humanoid

Character.HealthChanged:connect(function()
Gui.Size = UDim2.new((Humanoid.Health / Humanoid.MaxHealth),0,0.014,0)
end


--Let me know if i'm missing anything. Thanks DiamondBladee!
Report Abuse
Robobloxguy10 is not online. Robobloxguy10
Joined: 06 Sep 2012
Total Posts: 526
28 Jun 2016 10:27 PM
Bump
Report Abuse
Robobloxguy10 is not online. Robobloxguy10
Joined: 06 Sep 2012
Total Posts: 526
29 Jun 2016 08:01 AM
Bump
Report Abuse
Robobloxguy10 is not online. Robobloxguy10
Joined: 06 Sep 2012
Total Posts: 526
29 Jun 2016 08:43 AM
B.U.M.P
Report Abuse
Lem0nzzx is not online. Lem0nzzx
Joined: 08 Feb 2016
Total Posts: 1604
29 Jun 2016 08:46 AM
Character.Humanoid.Changed:connect(function()
Gui.Size = UDim2.new((Humanoid.Health / Humanoid.MaxHealth),0,0.014,0)
end



Report Abuse
Robobloxguy10 is not online. Robobloxguy10
Joined: 06 Sep 2012
Total Posts: 526
29 Jun 2016 09:04 AM
local Gui = script.Parent --ImageLabel
local Player = game.Players.LocalPlayer
local Character = Player.Character

Character.Humanoid.HealthChanged:connect(function()
Gui.Size = UDim2.new((Character.Humanoid.Health / Character.Humanoid.MaxHealth),0,0.014,0)
end)

This. Still. Won't. Work.

Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
29 Jun 2016 10:49 AM
Why is the Y scale so small?


"Tell me and I forget. Teach me and I remember. Involve me and I learn." - Benjamin Franklin
Report Abuse
Robobloxguy10 is not online. Robobloxguy10
Joined: 06 Sep 2012
Total Posts: 526
29 Jun 2016 12:24 PM
Healthbar is very small. The same issue still persists, the health bar gets bigger after health changes.
Report Abuse
Robobloxguy10 is not online. Robobloxguy10
Joined: 06 Sep 2012
Total Posts: 526
29 Jun 2016 12:28 PM
This is the health bar. Green is health.

https://gyazo.com/6dcfc697d871dca2bc4911f79ccf0df9
Report Abuse
runnergavin is not online. runnergavin
Joined: 04 Mar 2013
Total Posts: 468
29 Jun 2016 12:30 PM
Can you make a place and invite me to Studio? I think something else is wrong because the solutions should work.
Report Abuse
Robobloxguy10 is not online. Robobloxguy10
Joined: 06 Sep 2012
Total Posts: 526
29 Jun 2016 12:45 PM
Done
Report Abuse
Robobloxguy10 is not online. Robobloxguy10
Joined: 06 Sep 2012
Total Posts: 526
29 Jun 2016 12:50 PM
Whole Script: local Gui = script.Parent --ImageLabel
local Player = game.Players.LocalPlayer
local Character = Player.Character

Character.Humanoid.HealthChanged:connect(function()
Gui.Size = UDim2.new((Character.Humanoid.Health / Character.Humanoid.MaxHealth),0,0.014,0)
end)



--Let me know if i'm missing anything. Thanks DiamondBladee!
Report Abuse
runnergavin is not online. runnergavin
Joined: 04 Mar 2013
Total Posts: 468
29 Jun 2016 12:53 PM
link?
Report Abuse
Robobloxguy10 is not online. Robobloxguy10
Joined: 06 Sep 2012
Total Posts: 526
29 Jun 2016 12:53 PM
https://www.roblox.com/games/423193373/Legends-Of-Taranna-TESTING-REALM
Report Abuse
runnergavin is not online. runnergavin
Joined: 04 Mar 2013
Total Posts: 468
29 Jun 2016 12:54 PM
Joining.
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