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: Delay(arguments)

Previous Thread :: Next Thread 
Ristone3 is not online. Ristone3
Joined: 17 Aug 2008
Total Posts: 693
29 Mar 2017 01:19 PM
Hi! I am trying to pass arguments to a function I am calling in delay() I have tried the following ### #### to do it and neither works: delay(1,function(variable)) -- Says delay requires two arguments. delay(1,function,variable) --This one prints seemingly random doubles. Anyone know how to accomplish this?
Report Abuse
Lurching_Spark is not online. Lurching_Spark
Joined: 01 Oct 2016
Total Posts: 255
29 Mar 2017 01:28 PM
For some reason the wiki shows it as delay(1,function). I used it like that and it worked fine. Maybe you can't pass a variable to a function with delay? I'm not sure either.
Report Abuse
Ristone3 is not online. Ristone3
Joined: 17 Aug 2008
Total Posts: 693
29 Mar 2017 01:29 PM
I am glad I am not alone. Well, looks like it's time to do it another way!
Report Abuse
Lurching_Spark is not online. Lurching_Spark
Joined: 01 Oct 2016
Total Posts: 255
29 Mar 2017 01:29 PM
coroutines work really well.
Report Abuse
Lurching_Spark is not online. Lurching_Spark
Joined: 01 Oct 2016
Total Posts: 255
29 Mar 2017 01:30 PM
or else if you're just removing something after a bit of time you can use debris.
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
29 Mar 2017 02:28 PM
No, you're probably just using it incorrectly. Two default arguments are passed to the function, or the second argument, you call spawn with.

If you want to be able to call the function with your own arguments then just use a closure.


Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
29 Mar 2017 02:28 PM
delay*, however it works the same with spawn. They're both very similar functions.


Report Abuse
lovesicc is not online. lovesicc
Joined: 17 Dec 2016
Total Posts: 5
29 Mar 2017 02:32 PM
function a()
print("Hi")
end

delay(3, a)

--> Hi

function a()
print("Hi")
end

function a(str)
print(str)
end

delay(3, function()
a("Hi")
end)

--> Hi



Report Abuse
lovesicc is not online. lovesicc
Joined: 17 Dec 2016
Total Posts: 5
29 Mar 2017 02:35 PM
Woops,

function a()
print("Hi")
end
delay(3, a)
--> Hi

function a(str)
print(str)
end
delay(3, function()
a("Hi")
end)
--> Hi


Report Abuse
Lurching_Spark is not online. Lurching_Spark
Joined: 01 Oct 2016
Total Posts: 255
29 Mar 2017 02:40 PM
Good to know, thanks
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