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: Much confusion, not working..

Previous Thread :: Next Thread 
DarkheartSkillz is not online. DarkheartSkillz
Joined: 30 Sep 2011
Total Posts: 5125
02 May 2014 03:37 AM
while wait() do
script.Parent.Parent.Parent.Character:WaitForChild("Health"):Destroy()
end


script.Parent.Parent.Parent.Character:WaitForChild("Humanoid").Running:connect(function(speed)
if speed > 0 then return
else
a = script.Parent.Parent.Parent.Character:WaitForChild("Humanoid")
if a.Health > 0 and a.Health < 100 then
while wait(1) do
a.Health = a.Health + 1
end
end
end
end)

[ Xzavion War-Chief ] - [ TSC Imperator ]
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
02 May 2014 03:49 AM
WaitForChild blocks until the child appears, don't throw it around so often. The script may error less, but it will still stop working, except with no output because it just waits forever.
Report Abuse
DarkheartSkillz is not online. DarkheartSkillz
Joined: 30 Sep 2011
Total Posts: 5125
02 May 2014 03:55 AM
Okay, got that..

script.Parent.Parent.Parent.Character:WaitForChild("Humanoid").Running:connect(function(speed)
if speed > 0 then return
else
a = script.Parent.Parent.Parent.Character:WaitForChild("Humanoid")
if a.Health > 0 and a.Health < 100 then
while wait(1) do
a.Health = a.Health + 0.1
end
end
end
end)

Now the problem is, when I start walking again, the "While wait(1) do" function doesn't stop, it keeps regening the health..

[ Xzavion War-Chief ] - [ TSC Imperator ]
Report Abuse
Azarth is not online. Azarth
Joined: 17 Aug 2012
Total Posts: 2760
02 May 2014 04:02 AM
break it after something happens


literally use 'break'
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
02 May 2014 04:02 AM
Put the if statement inside the loop.
Report Abuse
DarkheartSkillz is not online. DarkheartSkillz
Joined: 30 Sep 2011
Total Posts: 5125
02 May 2014 04:11 AM
@Azarth
Where would I put the break? I put the break after the while wait(1) do loop, but that just made it stop when I stop walking.

[ Xzavion War-Chief ] - [ TSC Imperator ]
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
02 May 2014 04:12 AM
Swap these two lines:

if a.Health > 0 and a.Health < 100 then
while wait(1) do
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