|
| 12 Nov 2011 05:55 AM |
and I'm not sure it'll execute. Attempting to get the value to change accordingly with a Humanoid's Health value and react to damage by changing the Color3 of the TextLabel if it drops below a certain value.
Script:
HP = script.Parent.Parent.Parent.Parent:findFirstChild("Humanoid").Health
while true do HP = script.Parent.Text if HP > 25 then -- if it's bigger than 25 then script.Parent.TextColor3 = Color3.new(0, 255, 0) -- character is fine, label is green elseif HP =< 25 then -- if it's equal to or smaller than 25 then script.Parent.TextColor3 = Color3.new(255, 0, 0) -- character is hurt, label is red wait(0.1) end end
|
|
|
| Report Abuse |
|
|
1xCCx1
|
  |
| Joined: 07 Nov 2011 |
| Total Posts: 20 |
|
|
| 12 Nov 2011 06:03 AM |
I don't have much experience with LUA, but if it's anything like PHP, then it seems you are setting the HP variable at the start of the script, and then resetting it on each runthrough of the while!
1xC |
|
|
| Report Abuse |
|
|
|
| 12 Nov 2011 06:05 AM |
Let me explain a bit more:
Here's the humanoid, and let's say it has 100 HP. Now, we strike it with something, and it drops down to 75 HP. I'm trying to get the BillboardGUI to update every tenth of a second with the humanoid's health so I don't have to continually look in Studio to find out what the damage was. |
|
|
| Report Abuse |
|
|
1xCCx1
|
  |
| Joined: 07 Nov 2011 |
| Total Posts: 20 |
|
|
| 12 Nov 2011 06:13 AM |
I know that, But what you are doing is setting the first HP to the correct value, then CHANGING it on each runthrough of the while! Wait, let me rewrite that,
1xC |
|
|
| Report Abuse |
|
|
1xCCx1
|
  |
| Joined: 07 Nov 2011 |
| Total Posts: 20 |
|
|
| 12 Nov 2011 06:14 AM |
Script: HP = game.Workspace:findFirstChild("Humanoid").Health while true do if HP > 25 then -- if it's bigger than 25 then script.Parent.TextColor3 = Color3.new(0, 255, 0) -- character is fine, label is green elseif HP =< 25 then -- if it's equal to or smaller than 25 then script.Parent.TextColor3 = Color3.new(255, 0, 0) -- character is hurt, label is red wait(0.1) end end
1xC |
|
|
| Report Abuse |
|
|
|
| 12 Nov 2011 06:14 AM |
| @1xccx1: I disagree in my opinion. |
|
|
| Report Abuse |
|
|
|
| 12 Nov 2011 06:15 AM |
Like 1xC said, you are resetting it each time.
~ ~ ~ I have your soul, in my bag. |
|
|
| Report Abuse |
|
|
|
| 12 Nov 2011 06:15 AM |
| Yeah, but I was trying to change the value of the text to be the same as the humanoid's HP. |
|
|
| Report Abuse |
|
|
| |
|
|
| 12 Nov 2011 06:17 AM |
I know, but why are you making the same variable twice with two different meanings?
~ ~ ~ I have your soul, in my bag. |
|
|
| Report Abuse |
|
|
| |
|
|
| 12 Nov 2011 06:22 AM |
That's a fail on my part.
I'm trying to work on getting the value (Humanoid.Health) to become the text (TextLabel.Text). I thought that would work. |
|
|
| Report Abuse |
|
|
|
| 12 Nov 2011 06:30 AM |
Try this:
HP = script.Parent.Parent.Parent.Parent:findFirstChild("Humanoid") while true do HP.Health = script.Parent.Text if HP.Health > 25 then -- if it's bigger than 25 then script.Parent.TextColor3 = Color3.new(0, 255, 0) -- character is fine, label is green elseif HP.Health =< 25 then -- if it's equal to or smaller than 25 then script.Parent.TextColor3 = Color3.new(255, 0, 0) -- character is hurt, label is red wait(0.1) end end |
|
|
| Report Abuse |
|
|
|
| 12 Nov 2011 06:43 AM |
Returns this:
Sat Nov 12 07:41:52 2011 - Running Script "Workspace.Noob.Head.BillboardGui.Name.Script" Sat Nov 12 07:41:52 2011 - Workspace.Noob.Head.BillboardGui.Name.Script:4: 'then' expected near '?' |
|
|
| Report Abuse |
|
|
|
| 12 Nov 2011 07:25 AM |
HP = script.Parent.Parent.Parent.Parent:findFirstChild("Humanoid") while true do HP.Health = script.Parent.Text if HP.Health>25 then script.Parent.TextColor3 = Color3.new(0, 255, 0) elseif HP.Health=<25 then script.Parent.TextColor3 = Color3.new(255, 0, 0) wait(0.1) end end
that might work... Lua is sometimes annoying like that for me. |
|
|
| Report Abuse |
|
|
|
| 12 Nov 2011 07:26 AM |
HP = script.Parent.Parent.Parent.Parent:findFirstChild("Humanoid") while true do HP.Health = script.Parent.Text if HP.Health>25 then script.Parent.TextColor3 = Color3.new(0, 255, 0) elseif HP.Health=<25 then script.Parent.TextColor3 = Color3.new(255, 0, 0) end wait(0.1) end
sorry for double post, but you dont want to crash your game :0 |
|
|
| Report Abuse |
|
|
|
| 12 Nov 2011 07:28 AM |
| @ther, that won't crash the game it's got a wait in it. |
|
|
| Report Abuse |
|
|
|
| 12 Nov 2011 07:29 AM |
Try this:
HP = script.Parent.Parent.Parent.Parent:findFirstChild("Humanoid") while true do HP.Health = tonumber(script.Parent.Text) if HP.Health > 25 then script.Parent.TextColor3 = Color3.new(0, 255, 0) elseif HP.Health <= 25 then script.Parent.TextColor3 = Color3.new(255, 0, 0) wait(0.1) end end |
|
|
| Report Abuse |
|
|
|
| 12 Nov 2011 07:44 AM |
HP = script.Parent.Parent.Parent.Parent:findFirstChild("Humanoid")
while true do HP.Health = tonumber(script.Parent.Text) if HP.Health > 25 then script.Parent.TextColor3 = Color3.new(0, 255, 0) elseif HP.Health <= 25 then script.Parent.TextColor3 = Color3.new(255, 0, 0) wait(0.1) end end
look at where that wait is placed - it will only wait if HP.Health <= 25, so it will crash your game if HP.Health > 25
while true do HP.Health = tonumber(script.Parent.Text) if HP.Health>25 then script.Parent.TextColor3 = Color3.new(0, 255, 0) elseif HP.Health<=25 then script.Parent.TextColor3 = Color3.new(255, 0, 0) end wait(0.1) end |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 13 Nov 2011 01:31 PM |
Ok, it works, but the colors are off. I think I need to convert them to the 1 = 255 RGB scale. |
|
|
| Report Abuse |
|
|
|
| 13 Nov 2011 01:37 PM |
changing color 3, it has to be divided by 255
if it's gree (0/255, 255/255, 0/255) |
|
|
| Report Abuse |
|
|
| |
|
|
| 13 Nov 2011 01:40 PM |
I had fixed that because of the Wiki ( gotta love them color3 things ).
Thanks for the help! |
|
|
| Report Abuse |
|
|