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: How do you call 2 functions at once?

Previous Thread :: Next Thread 
robber4 is not online. robber4
Joined: 20 Jun 2008
Total Posts: 203
13 Aug 2013 10:04 AM
I try to call 2 functions at once, using one function.

function main()
derp()
derp2()
end

It never works. The first one, derp() in this case is the only one that is fired. I did this:

derp()
wait()
derp2()

but that didn't work either. Is there a way to do this?
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
13 Aug 2013 10:05 AM
Look up coroutines.
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
13 Aug 2013 10:08 AM
function derp()
print("Derp")
end
function derp2()
print("Derp2")
end
function main()
print("Main")
derp()
derp2()
end
main()

Did you have both derp functions? And did you remember to call the main function? What I pasted runs.
Report Abuse
robber4 is not online. robber4
Joined: 20 Jun 2008
Total Posts: 203
13 Aug 2013 10:10 AM
I just figured it out. It was coroutines that did the trick.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
13 Aug 2013 10:10 AM
@Lord

function derp()
wait(1)
print("Derp")
end
function derp2()
print("Derp2")
end
function main()
print("Main")
derp()
derp2()
end
main()

He wants it to print Derp2 before Derp1
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
13 Aug 2013 10:20 AM
No, I believe he wants it to print Derp before Derp2, and your code does exactly the same thing as mine except it won't print the two derps until a second after.

Furthermore, I don't think he really cares about printing "Derp". I think he just wanted to see how/if it is possible to call a function that calls two functions inside of it.
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
13 Aug 2013 10:21 AM
And now he's using coroutines to solve a problem that does not need them.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
13 Aug 2013 10:21 AM
He wanted Coroutines.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
13 Aug 2013 10:21 AM
Hence "Two functions at once"
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
13 Aug 2013 10:25 AM
He wanted to call two functions at once, not necessarily run two functions at once. It's very possible that he was unclear and wanted to run two functions at once, but I can only go off of what he told us in the thread. Each way could produce very different results.
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