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 » Scripters
Home Search
 

Re: Does an if statement with a function wait for the function?

Previous Thread :: Next Thread 
ROBOFROG is not online. ROBOFROG
Joined: 04 Jan 2009
Total Posts: 1519
07 Jul 2015 01:35 AM
Basically, if you create an if statement which is reliant on a return from a function (such as if testfunction(x) == "true"), will the if statement wait for the called function to return something, or will it only take its current value into consideration and move on?
Report Abuse
GeoVolcano is not online. GeoVolcano
Joined: 05 Jul 2012
Total Posts: 1433
07 Jul 2015 01:40 AM
You call a function after it has already been created. So therefore it's already true.
Report Abuse
AnimeWiki is not online. AnimeWiki
Joined: 26 Oct 2014
Total Posts: 460
07 Jul 2015 01:46 AM
I wish you could do this but it returns thread :(

local x = coroutine.create(function()
wait(1)
return true
end)


coroutine.resume(x)


repeat wait() until coroutine.status(x) == "dead"


print(x == true)
Report Abuse
ROBOFROG is not online. ROBOFROG
Joined: 04 Jan 2009
Total Posts: 1519
07 Jul 2015 01:57 AM
So basically, in that context, it will always return true as long as the function exists, no matter its return?
Report Abuse
AnimeWiki is not online. AnimeWiki
Joined: 26 Oct 2014
Total Posts: 460
07 Jul 2015 02:22 AM
it returns thread.
Report Abuse
ganger800 is not online. ganger800
Joined: 06 Dec 2012
Total Posts: 427
07 Jul 2015 03:56 AM
first let me fix it
unless your function returns a string containing the word "true" I don't think this is what you want
if testfunction(x) == "true" then
end

you probably want this:
if testfunction(x) then
end

answer to the question:
yes it will wait, since it will do something like this:
- if statement started
- calls function
- uses return to fill the statement, continues
however this is try with a function call

when you do
if testfunction then end
you take the memory address (no function call) and your script will run without waiting
Report Abuse
bubbaman73 is not online. bubbaman73
Joined: 02 Feb 2013
Total Posts: 795
07 Jul 2015 04:03 AM
if its in a function it waits


<3 cats <3
Report Abuse
AnimeWiki is not online. AnimeWiki
Joined: 26 Oct 2014
Total Posts: 460
07 Jul 2015 04:05 AM
@ganger800

ganger chan did i make bad thing :(
Report Abuse
ROBOFROG is not online. ROBOFROG
Joined: 04 Jan 2009
Total Posts: 1519
07 Jul 2015 01:45 PM
I appreciate the help, everybody! It was a confusing for a bit, but it's now cleared up with the best outcome possible.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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