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 » Scripting Helpers
Home Search
 

Re: Health

Previous Thread :: Next Thread 
WickedSiege is not online. WickedSiege
Joined: 03 Oct 2011
Total Posts: 3039
19 Jun 2014 05:16 PM
local human = script.Parent.Parent.Parent.Parent.Parent:WaitForChild("Zombie")

while true do
wait()
local pi = (human.Health / human.MaxHealth)
script.Parent.Size = UDim2.new(pi,0,0.8,0)
end


I'm not quite sure how to do this. I want the bar to not go over-sized. But stay a maximum size but decrease as the health goes down, get it?? Like, the bar stays one maximum size. Then, it decreases based on some stat... Help? Otherwise the bar keeps growing bigger and bigger!
Report Abuse
WickedSiege is not online. WickedSiege
Joined: 03 Oct 2011
Total Posts: 3039
19 Jun 2014 05:19 PM
I'm obviously not doing it correctly. What can I do to make the bar stay the same size, but decrease depending on the MaxHealth or something? Like the default roblox health bar?
Report Abuse
smiley599 is not online. smiley599
Joined: 23 Jan 2010
Total Posts: 21869
19 Jun 2014 05:21 PM
local human= game.Players.LocalPlayer.Character.Humanoid
human.HealthChanged:connect(function(health)
local pi = (human.Health / human.MaxHealth)
script.Parent.Size = UDim2.new(pi,0,0.8,0)
end)
Report Abuse
smiley599 is not online. smiley599
Joined: 23 Jan 2010
Total Posts: 21869
19 Jun 2014 05:21 PM
Oh god I'm sorry.

I thought this was for a player.

Ignore me then.
Report Abuse
WickedSiege is not online. WickedSiege
Joined: 03 Oct 2011
Total Posts: 3039
19 Jun 2014 05:23 PM
Thanks smiley, but when the function triggers, the bar stretches out very far. All I want to know is how to make this like the default roblox health bar!
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
19 Jun 2014 05:25 PM
"local pi"

We can all agree

That that is the best variable name ever.

As for the issue... It should work fine, unless Health can go over MaxHealth now... Or the bar's parent gets bigger.

Also, you should not create variables for a single purpose like that, it just creates more lag.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
19 Jun 2014 05:25 PM
Do you have an example where I can see the issue for myself?
Report Abuse
smiley599 is not online. smiley599
Joined: 23 Jan 2010
Total Posts: 21869
19 Jun 2014 05:26 PM
Does pi light up blue?

Put print(pi) because my guess is it's going to say 3.141 etc
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
19 Jun 2014 05:27 PM
Its because the syntax highlighter seems to be for a different version of Lua.
Report Abuse
WickedSiege is not online. WickedSiege
Joined: 03 Oct 2011
Total Posts: 3039
19 Jun 2014 05:28 PM
http://www.roblox.com/Fix-item?id=162206282

Here's the model of the AI. for all who wants to see the issue. Take the linkedsword or whatever, change it to kill zombies, and magically see what the bar does.
Report Abuse
LordMatthewII is not online. LordMatthewII
Joined: 20 Aug 2011
Total Posts: 10873
19 Jun 2014 05:33 PM
Don't use while do unless 100% Necessary.
Report Abuse
WickedSiege is not online. WickedSiege
Joined: 03 Oct 2011
Total Posts: 3039
19 Jun 2014 05:35 PM
Lord, it works just fine.
Report Abuse
LordMatthewII is not online. LordMatthewII
Joined: 20 Aug 2011
Total Posts: 10873
19 Jun 2014 05:37 PM
Just because it works DOESN'T MEAN IT WORKS GOOD.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
19 Jun 2014 05:38 PM
Ok, the issue is that you need to change Bar.Full not Bar.
Report Abuse
LordMatthewII is not online. LordMatthewII
Joined: 20 Aug 2011
Total Posts: 10873
19 Jun 2014 05:40 PM
For example, this creates one brick in workspace, but, it is very very bad.


while true do
wait()
part=Instance.new("Part")
part.Parent=workspace
part.Name="Lolpartlol"
part.Size=Vector3.new(10,10,1)
if workspace:FindFirstChild("Lolpartlol") then
workspace.Lolpartlol:Destroy()
end
end
Report Abuse
WickedSiege is not online. WickedSiege
Joined: 03 Oct 2011
Total Posts: 3039
19 Jun 2014 05:43 PM
Not, I don't really understand.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
19 Jun 2014 05:44 PM
You are changing "Bar", which is the background. What you ACTUALLY want is "Bar.Full"

script.Parent.Full

Look at the hierarchy.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
19 Jun 2014 05:45 PM
Although if I were you, I would try to merge every single script in the AI to a single script and improve the efficiency as a whole.
Report Abuse
WickedSiege is not online. WickedSiege
Joined: 03 Oct 2011
Total Posts: 3039
19 Jun 2014 05:47 PM
Not, I am currently doing that?
Report Abuse
WickedSiege is not online. WickedSiege
Joined: 03 Oct 2011
Total Posts: 3039
19 Jun 2014 05:51 PM
Even doing that makes the size crazy. Ugh, what to do.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
19 Jun 2014 05:52 PM
Sorry, looked again. Make it script.Parent.Fill

Hierarchy (From BillboardGui)

BillboardGui
+Health (This is also huge, btw)
++Full
+++Script
+++Fill (You want to modify this)
+++Frame
++Some other unrelated stuff
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
19 Jun 2014 05:53 PM
Also, why is BillboardGui 40 studs wide with Health transparent (And also really large)?

You should probably have a quick redesign :P
Report Abuse
WickedSiege is not online. WickedSiege
Joined: 03 Oct 2011
Total Posts: 3039
19 Jun 2014 05:55 PM
Using fill works! Thanks so much!
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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