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 BAR

Previous Thread :: Next Thread 
Fall3nGod is not online. Fall3nGod
Joined: 30 Jan 2014
Total Posts: 1323
01 May 2016 10:58 AM
so how do i put a custom health bar on a surface gui? and how do i make that gui follow the player
Report Abuse
iJacobness is not online. iJacobness
Joined: 20 Jan 2014
Total Posts: 4944
01 May 2016 10:59 AM
weld or cframe lerping,

and udim2


Report Abuse
Fall3nGod is not online. Fall3nGod
Joined: 30 Jan 2014
Total Posts: 1323
01 May 2016 11:02 AM
i tried and it didnt work, or at least i think i did it right
Report Abuse
iJacobness is not online. iJacobness
Joined: 20 Jan 2014
Total Posts: 4944
01 May 2016 11:03 AM
i doubt you did, what's your script?


Report Abuse
Fall3nGod is not online. Fall3nGod
Joined: 30 Jan 2014
Total Posts: 1323
01 May 2016 11:10 AM
WORKSPACE

part
local script
Health_Bar (surface gui)
Health_Back
Main





-- Player, Character, and Humanoid.
local plr = game.Players.LocalPlayer
local plr_Char = plr.Character
local plr_Human = plr_Char.Humanoid


local gui_Name = "Health_Bar"
local back_Name = "Health_Back"
local main_Name = "Main"

-- Updates the bar.
function update()
-- Sets up the sizing parameters.
local hp_Math = plr_Human.Health / plr_Human.MaxHealth
-- Finds the main bar.
local bar = plr.PlayerGui[gui_Name][back_Name][main_Name]
-- Resizes the main bar.
bar.Size = UDim2.new(hp_Math,0,1,0)
end

-- Runs the function at startup
update()
-- Runs the function after health changes.
plr_Human.Changed:connect(update)




however the whole thing may need changing :/
Report Abuse
cgjnm is not online. cgjnm
Joined: 22 Dec 2011
Total Posts: 2347
01 May 2016 11:12 AM
http://wiki.roblox.com/index.php?title=API:Class/SurfaceGui/Adornee
Report Abuse
Fall3nGod is not online. Fall3nGod
Joined: 30 Jan 2014
Total Posts: 1323
01 May 2016 11:14 AM
this may be important as well

the code for the normal gui health on mine


local Player = Game.Players.LocalPlayer

repeat wait() until Player.Character ~= nil
repeat wait() until Player.Character:FindFirstChild("Humanoid")
repeat wait() until Player.leaderstats
repeat wait() until Player.Stats

Player.leaderstats:WaitForChild("Lvl")
Player.leaderstats:WaitForChild("Gold")

local HUD = Game.Players.LocalPlayer.PlayerGui.HUD

HUD.Base:WaitForChild("HealthBar")
HUD.Base.HealthBar:WaitForChild("Fill")
HUD.Base.HealthBar:WaitForChild("CurrentHP")

HUD.Base:WaitForChild("ManaBar")
HUD.Base.ManaBar:WaitForChild("Fill")
HUD.Base.ManaBar:WaitForChild("CurrentMP")


Player.Character:WaitForChild("Humanoid").Died:connect(ShowGameOver)

while true do
if Player.Character:FindFirstChild("Humanoid") ~= nil then
if Game.Workspace.GAME_PROPERTIES.DefenseMode.Value == 3 then
if Player.Stats:FindFirstChild("Defense") ~= nil then
Player.Character.Humanoid.MaxHealth = (Game.Workspace.GAME_PROPERTIES.StartingHP.Value) + (Game.Workspace.GAME_PROPERTIES.HPPerLevel.Value * Player.leaderstats.Lvl.Value) + (Game.Workspace.GAME_PROPERTIES.HPPerConstitution.Value * Player.attributes.Constitution.Value) + Player.Stats.Defense.Value
end
else
Player.Character.Humanoid.MaxHealth = (Game.Workspace.GAME_PROPERTIES.StartingHP.Value) + (Game.Workspace.GAME_PROPERTIES.HPPerLevel.Value * Player.leaderstats.Lvl.Value) + (Game.Workspace.GAME_PROPERTIES.HPPerConstitution.Value * Player.attributes.Constitution.Value)
end
end
Game.Players.LocalPlayer.Stats.MaxMana.Value = (Game.Workspace.GAME_PROPERTIES.StartingMP.Value) + (Game.Workspace.GAME_PROPERTIES.MPPerLevel.Value * Player.leaderstats.Lvl.Value) + (Game.Workspace.GAME_PROPERTIES.MPPerIntelligence.Value * Player.attributes.Intelligence.Value)
--Refresh speed and gold display.
HUD.Base.WalkSpeed.Text = math.floor(Player.Character.Humanoid.WalkSpeed)
HUD.Base.GoldBox.Text = Player.leaderstats.Gold.Value
--Refresh character icon.
HUD.Base.CharacterPortrait.Character.Image = "http://www.roblox.com/thumbs/avatar.ashx?x=352&y=352&format=png&username=" ..Game.Players.LocalPlayer.Name
HUD.Base.CharacterPortrait.Level.Text = "Lvl " .. Player.leaderstats.Lvl.Value
--Refresh health and mana bar.
if Player.Character:FindFirstChild("Humanoid") ~= nil then
HUD.Base.HealthBar.CurrentHP.Text = "HP: " .. math.floor(Player.Character.Humanoid.Health) .. " / " .. Player.Character.Humanoid.MaxHealth
HUD.Base.HealthBar.Fill.Size = UDim2.new(0, (Player.Character.Humanoid.Health / Player.Character.Humanoid.MaxHealth) * 150, 0, 20)
if Player.Character.Humanoid.Health < (Player.Character.Humanoid.MaxHealth / 4) and Player.Character.Humanoid.Health > 0 then
HUD.Critical.Visible = true
else
HUD.Critical.Visible = false
end
end
HUD.Base.ManaBar.CurrentMP.Text = "MP: " .. Player.Stats.Mana.Value .. " / " .. Player.Stats.MaxMana.Value
HUD.Base.ManaBar.Fill.Size = UDim2.new(0, (Player.Stats.Mana.Value / Player.Stats.MaxMana.Value) * 150, 0, 20)
wait(0.1)
end
Report Abuse
Fall3nGod is not online. Fall3nGod
Joined: 30 Jan 2014
Total Posts: 1323
01 May 2016 11:18 AM
this may be important as well

the code for the normal gui health on mine


local Player = Game.Players.LocalPlayer


local HUD = Game.Players.LocalPlayer.PlayerGui.HUD

HUD.Base:WaitForChild("HealthBar")
HUD.Base.HealthBar:WaitForChild("Fill")
HUD.Base.HealthBar:WaitForChild("CurrentHP")

HUD.Base:WaitForChild("ManaBar")
HUD.Base.ManaBar:WaitForChild("Fill")
HUD.Base.ManaBar:WaitForChild("CurrentMP")


Player.Character:WaitForChild("Humanoid").Died:connect(ShowGameOver)

while true do
if Player.Character:FindFirstChild("Humanoid") ~= nil then
if Game.Workspace.GAME_PROPERTIES.DefenseMode.Value == 3 then
if Player.Stats:FindFirstChild("Defense") ~= nil then
Player.Character.Humanoid.MaxHealth = (Game.Workspace.GAME_PROPERTIES.StartingHP.Value) + (Game.Workspace.GAME_PROPERTIES.HPPerLevel.Value * Player.leaderstats.Lvl.Value) + (Game.Workspace.GAME_PROPERTIES.HPPerConstitution.Value * Player.attributes.Constitution.Value) + Player.Stats.Defense.Value
end
else
Player.Character.Humanoid.MaxHealth = (Game.Workspace.GAME_PROPERTIES.StartingHP.Value) + (Game.Workspace.GAME_PROPERTIES.HPPerLevel.Value * Player.leaderstats.Lvl.Value) + (Game.Workspace.GAME_PROPERTIES.HPPerConstitution.Value * Player.attributes.Constitution.Value)
end
end
Game.Players.LocalPlayer.Stats.MaxMana.Value = (Game.Workspace.GAME_PROPERTIES.StartingMP.Value) + (Game.Workspace.GAME_PROPERTIES.MPPerLevel.Value * Player.leaderstats.Lvl.Value) + (Game.Workspace.GAME_PROPERTIES.MPPerIntelligence.Value * Player.attributes.Intelligence.Value)
--Refresh health and mana bar.
if Player.Character:FindFirstChild("Humanoid") ~= nil then
HUD.Base.HealthBar.CurrentHP.Text = "HP: " .. math.floor(Player.Character.Humanoid.Health) .. " / " .. Player.Character.Humanoid.MaxHealth
HUD.Base.HealthBar.Fill.Size = UDim2.new(0, (Player.Character.Humanoid.Health / Player.Character.Humanoid.MaxHealth) * 150, 0, 20)
if Player.Character.Humanoid.Health < (Player.Character.Humanoid.MaxHealth / 4) and Player.Character.Humanoid.Health > 0 then
HUD.Critical.Visible = true
else
HUD.Critical.Visible = false
end
end
HUD.Base.ManaBar.CurrentMP.Text = "MP: " .. Player.Stats.Mana.Value .. " / " .. Player.Stats.MaxMana.Value
HUD.Base.ManaBar.Fill.Size = UDim2.new(0, (Player.Stats.Mana.Value / Player.Stats.MaxMana.Value) * 150, 0, 20)
wait(0.1)
end
Report Abuse
Fall3nGod is not online. Fall3nGod
Joined: 30 Jan 2014
Total Posts: 1323
01 May 2016 11:25 AM
soooooooo no help?
Report Abuse
iJacobness is not online. iJacobness
Joined: 20 Jan 2014
Total Posts: 4944
01 May 2016 11:27 AM
um, thats way too long for what you asked for, read the wiki. dont use free models


Report Abuse
cgjnm is not online. cgjnm
Joined: 22 Dec 2011
Total Posts: 2347
01 May 2016 11:27 AM
I'm not reading all that scripting, but maybe these will help:
http://wiki.roblox.com/index.php?title=API:Class/SurfaceGui/Adornee
http://wiki.roblox.com/index.php?title=API:Class/SurfaceGui
Report Abuse
Fall3nGod is not online. Fall3nGod
Joined: 30 Jan 2014
Total Posts: 1323
01 May 2016 11:34 AM
ok that scipting isnt neccesary (lets just say)
how would i do it?

can someone like just tell me how to place stuff e.g
part
surface gui
etc

and what to put in the script?
Report Abuse
cgjnm is not online. cgjnm
Joined: 22 Dec 2011
Total Posts: 2347
01 May 2016 11:34 AM
Are you ignoring what I am posting?


http://wiki.roblox.com/index.php?title=API:Class/SurfaceGui/Adornee
http://wiki.roblox.com/index.php?title=API:Class/SurfaceGui
Report Abuse
Fall3nGod is not online. Fall3nGod
Joined: 30 Jan 2014
Total Posts: 1323
01 May 2016 11:42 AM
its kinda confusing

Report Abuse
iJacobness is not online. iJacobness
Joined: 20 Jan 2014
Total Posts: 4944
01 May 2016 11:44 AM
yet u scripted all of that..


Report Abuse
Fall3nGod is not online. Fall3nGod
Joined: 30 Jan 2014
Total Posts: 1323
01 May 2016 11:45 AM
WAIT NVM I DID IT



HOW DO I ATTACH IT TO MY GUY
Report Abuse
Fall3nGod is not online. Fall3nGod
Joined: 30 Jan 2014
Total Posts: 1323
01 May 2016 12:03 PM
bump
Report Abuse
Fall3nGod is not online. Fall3nGod
Joined: 30 Jan 2014
Total Posts: 1323
01 May 2016 12:13 PM
how do i make it follow the player
right now its in
game.startergui.HUD (HUD is the block its all on)
Report Abuse
kools is not online. kools
Joined: 11 Jan 2009
Total Posts: 1659
01 May 2016 12:24 PM
The person above was suggesting you use a surface gui which is not in the player's gui, but in the world. To attach it to the player, set the adornee to the player's head.

I would suggest putting the surfacegui in the player's startergear and using a script to parent it to that player's head.
Report Abuse
kools is not online. kools
Joined: 11 Jan 2009
Total Posts: 1659
01 May 2016 12:27 PM
A suggestion I also have for you is to PLEASE not loop code in a while true do loop. It's not too good for your server's performance. Instead you can use events. For example, to update the player's HUD when their health changes, connect to HealthChanged. (http://wiki.roblox.com/index.php?title=API:Class/Humanoid/HealthChanged)
Report Abuse
Fall3nGod is not online. Fall3nGod
Joined: 30 Jan 2014
Total Posts: 1323
01 May 2016 12:30 PM
where do i find the adornee?
sorry i am new to this
Report Abuse
Fall3nGod is not online. Fall3nGod
Joined: 30 Jan 2014
Total Posts: 1323
01 May 2016 12:34 PM
btw
i put it hud in workspace and it is no longer working
Report Abuse
kools is not online. kools
Joined: 11 Jan 2009
Total Posts: 1659
01 May 2016 12:36 PM
Woops a quick look at http://wiki.roblox.com/index.php?title=API:Class/SurfaceGui makes it clear to me that it actually still belongs in the startergui folder my bad. Adornee, if you actually checked out the link, is a property of a surfacegui, you can edit it with a script, or experiment using the properties panel in studio.
Report Abuse
Fall3nGod is not online. Fall3nGod
Joined: 30 Jan 2014
Total Posts: 1323
01 May 2016 12:42 PM
oh i was wondering why i couldnt just change adornee through properties

and also is this how the adornee works?

syrfacegui.adornee.loacl player torso
?
Report Abuse
cgjnm is not online. cgjnm
Joined: 22 Dec 2011
Total Posts: 2347
01 May 2016 12:44 PM
Gui.Adornee = Character.Head
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