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
 

local variable = function():wait()

Previous Thread :: Next Thread 
ClassicalGod is not online. ClassicalGod
Joined: 26 Sep 2008
Total Posts: 2842
28 Sep 2016 09:30 AM
How do I set a variable to what a function returns and wait until that function yields before continuing the script?

It was something like my title I swear, but I can't remember it exactly.
Report Abuse
Toonshield is online. Toonshield
Joined: 04 Mar 2015
Total Posts: 518
28 Sep 2016 09:33 AM
The script always yield before a function returns.
Report Abuse
ClassicalGod is not online. ClassicalGod
Joined: 26 Sep 2008
Total Posts: 2842
28 Sep 2016 09:35 AM
oh.

I probably wrote the script wrong.

Alright, thread's over everyone.
Report Abuse
1WithTheNoobiestNoob is not online. 1WithTheNoobiestNoob
Joined: 24 Jun 2012
Total Posts: 145
28 Sep 2016 12:19 PM
It cant be a function

It has to be an event

Report Abuse
batistapowerbonbtla is not online. batistapowerbonbtla
Joined: 16 Dec 2011
Total Posts: 2203
28 Sep 2016 12:23 PM
CharacterAdded:wait()
?

https://www.roblox.com/library/359444683/H-W-A-Arrow
Report Abuse
1WithTheNoobiestNoob is not online. 1WithTheNoobiestNoob
Joined: 24 Jun 2012
Total Posts: 145
28 Sep 2016 12:26 PM
CharacterAdded is an event

here is another example

local Bindable = Instance.new("BindableEvent")

local Event = Bindable.Event

Event:connect(function()
print("YAY")
end)

coroutine.wrap(function()
Event:wait()
print("it fired")
end)()

wait(1)
Event:Fire()
Report Abuse
1WithTheNoobiestNoob is not online. 1WithTheNoobiestNoob
Joined: 24 Jun 2012
Total Posts: 145
28 Sep 2016 12:28 PM
probably

Bindable:Fire()

instead

because i think Event:Fire() might not work

but yes it only works for events unless you make a table with a wait function

local fake = {fire = false;}
function fake:wait()
repeat wait until self.fire
end

coroutine.wrap(function()
fake:wait()
print("fired")
end)()

wait(1)
fake.fire = true
Report Abuse
1WithTheNoobiestNoob is not online. 1WithTheNoobiestNoob
Joined: 24 Jun 2012
Total Posts: 145
28 Sep 2016 12:29 PM
repeat wait() until self.fire
*

self is just returned by the method
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