Libraries+, a library extension module

I got a chance to check some of it out.

WaitForChildOfClass = function(instance, class_name, timeout) -- Wait for a child of class
	if type(timeout) == "number" then
		wait(timeout)
		return instance:FindFirstChildOfClass(class_name)
	end
	while not instance:FindFirstChildOfClass(class_name) do
		instance.ChildAdded:Wait()
	end
	return instance:FindFirstChildOfClass(class_name)
end

This isn’t the intended functionality of ‘WaitForChild’. If given a Timeout, this will simply stall the entire time duration (ignoring any instances created in the intermission) and then spit-out an already existing Instance that fits the criteria. Check out this post on how you may actually implement this correctly. (Of course, substituting the now deprecated RbxUtility signal for a BindableEvent.)

1 Like