|
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 19 Jun 2014 05:25 PM |
| Do you have an example where I can see the issue for myself? |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 19 Jun 2014 05:27 PM |
| Its because the syntax highlighter seems to be for a different version of Lua. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 19 Jun 2014 05:33 PM |
| Don't use while do unless 100% Necessary. |
|
|
| Report Abuse |
|
|
| |
|
|
| 19 Jun 2014 05:37 PM |
| Just because it works DOESN'T MEAN IT WORKS GOOD. |
|
|
| Report Abuse |
|
|
|
| 19 Jun 2014 05:38 PM |
| Ok, the issue is that you need to change Bar.Full not Bar. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 19 Jun 2014 05:43 PM |
| Not, I don't really understand. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 19 Jun 2014 05:47 PM |
| Not, I am currently doing that? |
|
|
| Report Abuse |
|
|
|
| 19 Jun 2014 05:51 PM |
| Even doing that makes the size crazy. Ugh, what to do. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 19 Jun 2014 05:55 PM |
| Using fill works! Thanks so much! |
|
|
| Report Abuse |
|
|