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: Stop a function in its path (how?)

Previous Thread :: Next Thread 
Dinizterz is not online. Dinizterz
Joined: 08 Oct 2008
Total Posts: 4193
03 Oct 2013 05:57 PM
It's always been on my mind, it could be just a simple line of code, but after some research I can't seem to find it. What I'm looking for is to stop a function while it's running. I looked at coroutines for this, but it seems that the coroutine function can only be stopped if the "coroutine.yield" is INSIDE the coroutine function. I think I'm misunderstanding coroutines, but the goal is to stop a function in its path. Something along the lines of this:

function soar()
wait(1)
print("take off")
wait(1)
print("soaring")
wait(1)
print("still soaring")
wait(1)
print("done soaring.")
end

soaringbool.Changed:connect(function()
if soaringbool.Value == true then soar() else [STOP THE SOAR FUNCTION] end
end)

I want to know because my current method is to clone a script with a function when a boolvalue is true, and when the boolvalue turns false which could be in the middle of the cloned script's function, the cloned script is destroyed, alternatively stopping a function in it's path. How do you do it in a more efficient way? Coroutine.yield? A function manipulation i'm missing? Thanks.
Report Abuse
morash is not online. morash
Joined: 22 May 2010
Total Posts: 5834
03 Oct 2013 06:03 PM
I think it's "break (function)" but I haven't used this so I wouldn't know.
Report Abuse
FrozenSmite is not online. FrozenSmite
Joined: 17 Jul 2013
Total Posts: 2242
03 Oct 2013 06:26 PM
U could also use a variable in the funtion that checks if its true

♫♪ repeat wait() until game.Players.FrozenSmite.HasALife == true ♪♫
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
03 Oct 2013 06:45 PM
You can check if the BoolValue is still true within the function you made.
Report Abuse
Dinizterz is not online. Dinizterz
Joined: 08 Oct 2008
Total Posts: 4193
05 Oct 2013 08:58 PM
I've come to that method, xXxMonkey, but it seems way too inefficient. To make it look less ugly I could use a for loop.
Report Abuse
Dinizterz is not online. Dinizterz
Joined: 08 Oct 2008
Total Posts: 4193
06 Oct 2013 06:32 PM
Bump
Report Abuse
sam8985 is not online. sam8985
Joined: 12 Nov 2011
Total Posts: 582
06 Oct 2013 06:46 PM
return end
Report Abuse
sam8985 is not online. sam8985
Joined: 12 Nov 2011
Total Posts: 582
06 Oct 2013 06:47 PM
Nvm
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