NOTE - This is a re-post/duplicate question to this here. Though it didn't get much of a response, (since I posted it @ 2:00 in the morning) so I'm asking this again.

I was wondering this as I wanted a more precise solution to yielding a thread. Consider this:

Instead of doing this

local conditional

spawn(function()
	repeat wait() until conditional
	--do stuff
end)
	 
wait(1)
conditional = true

One could do this:

local conditional = Instance.new("BindableEvent")

spawn(function()
	conditional.Event:Wait()
	--do stuff
end)

wait(1)
conditional:Fire()

Though wan't fully sure if an instance not parented to the DataModel would automaticly despawn and get removed after awhile.

7 comments

0

Don't duplicate a question.

0

Well it didn't garner much of a response in the first place. Should I turn to the forums instead?

0

I believe the garbage collector won't pick up something as long as something else still references it

0

You could just do conditional:Destroy() in the do stuff area.

0

conditional.Event:Wait() Why not set up a function instead of using a coroutine?

0

Ah I see. I knew that connections to an instance wouldn't be broken until the object was destroyed or disconnected, though I just wanted to confirm that a referenced Instance that isn't parented to the datamodel wouldn't despawn or something.