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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Previous Thread :: Next Thread 
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
31 Jan 2015 10:11 PM
I've heard of them a lot lately, what does spawn(function() end) and delay() do?
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
31 Jan 2015 10:13 PM
spawn creates a new function when the script isn't busy, and delay delays the given amount of time before executing the given function
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
31 Jan 2015 10:16 PM
spawn(function()
wait(5)
print("Hello")
end)

print("Bye")

Output
Bye
5 seconds later
Hello


delay(5, function()
print("Hello")
end)

print("Bye")

Output
Bye
5 seconds later
Hello
Report Abuse
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
01 Feb 2015 12:26 AM
Ok thanks! I understand delay but I still don't understand spawn :/
Report Abuse
Seranok is not online. Seranok
Joined: 12 Dec 2009
Total Posts: 11083
01 Feb 2015 12:29 AM
spawn(function_goes_here) is like you created a new script to run the given function

So let's say you do this:

function print123()

for i = 1, 3 do
print(i)
wait(1)
end

end

spawn(print123)
print123()

Then the results will be:

1
1
2
2
3
3

This is because the spawned thread and the script's main thread are being executed at the same time.
Report Abuse
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
01 Feb 2015 12:31 AM
Ah ok, now I think I understand better, so it's like delay() is the opposite of spawn().
Thanks.
Report Abuse
ChiefDelta is not online. ChiefDelta
Joined: 05 Nov 2010
Total Posts: 13071
01 Feb 2015 12:31 AM
they exist so you never have to use coroutines ever again
Report Abuse
Seranok is not online. Seranok
Joined: 12 Dec 2009
Total Posts: 11083
01 Feb 2015 12:32 AM
Well delay is basically this:

function delay(t, f)
    wait(t)
    f()
end
Report Abuse
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
01 Feb 2015 12:32 AM
Niceeeee!
Report Abuse
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
01 Feb 2015 12:33 AM
Oh, and thanks!
Report Abuse
Seranok is not online. Seranok
Joined: 12 Dec 2009
Total Posts: 11083
01 Feb 2015 12:33 AM
Sorry I meant to post:

function delay(t, f)
    spawn(function()
        wait(t)
        f()
    end)
end
Report Abuse
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
01 Feb 2015 12:57 AM
Oh ok, thanks for the help!
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