|
| 27 Jul 2012 04:24 PM |
while true do wait(0.05) hp = script.Parent.Parent.Health.Value if hp > 100 then hp = 100 end end
What I have tried: - Replacing the '>' with '<' - Using an equation in place of 'hp = 100'
What is not the problem: - The infinite loop. This is to check the value of 'hp' constantly and to repair it if it overflows. It works fine with the other two scripts I am using it with. - The 'if then' statement. It works fine with one of my other scripts that use it.
The idea is that if the value 'hp' is more than one hundred, it will be brought back to one hundred to prevent HP overflow in a model that I am making. Also, if anyone has a more efficient way of doing this, I would be glad to see it. |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2012 04:31 PM |
I don't think you can determine Value entities with tags.
You have to directly "link" to the value (I believe).
~>NEED A DISPENSER HERE!<~ |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2012 04:33 PM |
| No, my other scripts use that and it works fine. I guess I forgot to include that in the 'Not the problem' list. But I'll try it. |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2012 04:34 PM |
Does it return an error?
~>NEED A DISPENSER HERE!<~ |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2012 04:37 PM |
| No, it doesn't return any error. |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2012 04:38 PM |
Try setting it up to call a function ( Heal(), maybe? )
I'm thinking it might be the extra end.
~>NEED A DISPENSER HERE!<~ |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2012 04:40 PM |
The extra end is needed for the 'if then' statement. Maybe setting up a function will work, so I'll try that. |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2012 04:46 PM |
Maybe you need an else statement for the if...
~>NEED A DISPENSER HERE!<~ |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2012 04:47 PM |
| Okay, the function didn't work at all, and still didn't return any errors. |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2012 04:47 PM |
Try this.
while wait(0.05) do if script.Parent.Parent:IsA("Humanoid") then if script.Parent.Parent.Health.Value>100 then script.Parent.Parent.Health=100 end end end
--TehChikenHater ლ(ಠ_ಠლ)
--TehChikenHater ლ(ಠ_ಠლ) |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2012 04:52 PM |
The value I'm working with is not a humanoid, and I'd prefer to avoid using them, due to the fact that they aren't as dynamic as variables which you can add and remove as you please.
Also, I doubt adding an 'else' to my script would help, and honestly, I'm not sure how I would apply it to this situation. Also, another script with the same 'else if' statement does not need an 'else', and works perfectly. |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2012 04:53 PM |
| Argh, I mean 'if then', not 'else if'. |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2012 04:53 PM |
Oh sorry, I thought you were working with a humanoid. Try this.
while wait(0.05) do if script.Parent.Parent then if script.Parent.Parent.Health.Value>100 then script.Parent.Parent.Health.Value=100 end end end
Make sure the name is Health, make sure the value is a NumValue, not a String, and make sure the path to it is correct.
--TehChikenHater ლ(ಠ_ಠლ)
--TehChikenHater ლ(ಠ_ಠლ) |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2012 05:00 PM |
| Well, that seems to work. Thank you for helping! Is there any way I can at least attempt do something for you to thank you? |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2012 05:29 PM |
That will lag your game. You should use HealthChanged instead.
function change() if script.Parent.Parent and script.Parent.Parent:IsA("Humanoid") then if script.Parent.Parent.Health.Value > 100 then script.Parent.Parent.Health.Value = 100 end end end script.Parent.Parent.HealthChanged:connect(change) |
|
|
| Report Abuse |
|
|