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: Functions

Previous Thread :: Next Thread 
evildoomsayer is online. evildoomsayer
Joined: 28 Jun 2011
Total Posts: 1443
01 Apr 2014 09:18 PM
Is there a way to stop a function?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
01 Apr 2014 09:18 PM
return
Report Abuse
evildoomsayer is online. evildoomsayer
Joined: 28 Jun 2011
Total Posts: 1443
01 Apr 2014 09:20 PM
k thanks. I just never really use returns... *watching-you sign on return*
Report Abuse
OzzyBlox is not online. OzzyBlox
Joined: 04 Nov 2009
Total Posts: 14166
01 Apr 2014 09:22 PM
or Script:Destroy() >:D
Report Abuse
evildoomsayer is online. evildoomsayer
Joined: 28 Jun 2011
Total Posts: 1443
01 Apr 2014 09:24 PM
nop. I know how to script,I just don't use return.
Report Abuse
OzzyBlox is not online. OzzyBlox
Joined: 04 Nov 2009
Total Posts: 14166
01 Apr 2014 09:24 PM
I know I was joking. Script:Destroy is not a good idea.
Report Abuse
evildoomsayer is online. evildoomsayer
Joined: 28 Jun 2011
Total Posts: 1443
01 Apr 2014 09:25 PM
plus that face gave a dead giveaway that it wouldn't be good to do. Plus,all you got to do is read it and yea. Even a beginner with no scripting knowledge could know.
Report Abuse
OzzyBlox is not online. OzzyBlox
Joined: 04 Nov 2009
Total Posts: 14166
01 Apr 2014 09:26 PM
Yes yes yes I know it was simply a joke. No need to explain how you know thats a bad idea.
Report Abuse
evildoomsayer is online. evildoomsayer
Joined: 28 Jun 2011
Total Posts: 1443
01 Apr 2014 09:28 PM
ik @Ozzy lol
Report Abuse
evildoomsayer is online. evildoomsayer
Joined: 28 Jun 2011
Total Posts: 1443
01 Apr 2014 09:28 PM
@Ozzy Ik i am einsteiin. (jk)
Report Abuse
evildoomsayer is online. evildoomsayer
Joined: 28 Jun 2011
Total Posts: 1443
01 Apr 2014 09:30 PM
btw return didn't work. But,I used a if statement instead.
Report Abuse
robotmega is not online. robotmega
Joined: 16 May 2009
Total Posts: 14084
01 Apr 2014 09:54 PM
because you dont know how to use return
Report Abuse
roboslayer10 is not online. roboslayer10
Joined: 08 Aug 2011
Total Posts: 206
01 Apr 2014 09:55 PM
if your trying to stop a function, its probably best to use if statements determining whether to go through with it. For example, if its a function that has no wait times, its not that big of a deal, just have the if statements determining the action.

However, if it is a loop, then I would prefer...


running = false

function run()
if running == true then
while running == true do
wait()
if running = false then
break
end
end
end
end



This would be commonly used in a sprint script, such that when a player presses Shift, it would start running and turn running to true, and while he holds shift, he stays running, and when he releases shift, the running statement would become false again, therefore stopping the function.

I hope that made sense.
Report Abuse
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
01 Apr 2014 10:56 PM
You can return values too.

This would be a pointless function, but it shows what I mean.

repeat wait() until f()

function f()
if game.Players.NumPlayers > 1 then
return true
end
return false
end

It basically pauses the script until at least two players are in the game.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
01 Apr 2014 10:59 PM
Put the function above the repeat loop.
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
01 Apr 2014 11:42 PM
Yeah. return breaks a function, just like break breaks a loop.

EX;

script.Parent.Touched:connect(function(hit)
if hit.Name = "DerpedOut" then
return
else
print("Phew, DerpedOut didn't touch us (:")
end end)
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