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: This script isn't working, but I don't see why.

Previous Thread :: Next Thread 
FruitTheRobot is not online. FruitTheRobot
Joined: 24 Jul 2011
Total Posts: 8801
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
SundownMKII is not online. SundownMKII
Joined: 26 Sep 2010
Total Posts: 12880
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
FruitTheRobot is not online. FruitTheRobot
Joined: 24 Jul 2011
Total Posts: 8801
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
SundownMKII is not online. SundownMKII
Joined: 26 Sep 2010
Total Posts: 12880
27 Jul 2012 04:34 PM
Does it return an error?

~>NEED A DISPENSER HERE!<~
Report Abuse
FruitTheRobot is not online. FruitTheRobot
Joined: 24 Jul 2011
Total Posts: 8801
27 Jul 2012 04:37 PM
No, it doesn't return any error.
Report Abuse
SundownMKII is not online. SundownMKII
Joined: 26 Sep 2010
Total Posts: 12880
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
FruitTheRobot is not online. FruitTheRobot
Joined: 24 Jul 2011
Total Posts: 8801
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
SundownMKII is not online. SundownMKII
Joined: 26 Sep 2010
Total Posts: 12880
27 Jul 2012 04:46 PM
Maybe you need an else statement for the if...

~>NEED A DISPENSER HERE!<~
Report Abuse
FruitTheRobot is not online. FruitTheRobot
Joined: 24 Jul 2011
Total Posts: 8801
27 Jul 2012 04:47 PM
Okay, the function didn't work at all, and still didn't return any errors.
Report Abuse
builderman1171 is not online. builderman1171
Joined: 27 Mar 2010
Total Posts: 1595
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
FruitTheRobot is not online. FruitTheRobot
Joined: 24 Jul 2011
Total Posts: 8801
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
FruitTheRobot is not online. FruitTheRobot
Joined: 24 Jul 2011
Total Posts: 8801
27 Jul 2012 04:53 PM
Argh, I mean 'if then', not 'else if'.
Report Abuse
builderman1171 is not online. builderman1171
Joined: 27 Mar 2010
Total Posts: 1595
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
FruitTheRobot is not online. FruitTheRobot
Joined: 24 Jul 2011
Total Posts: 8801
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
Bob123456789103570 is not online. Bob123456789103570
Joined: 23 Dec 2008
Total Posts: 9531
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
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