WaitForChildOfClass function

Hi Developers, I wanted to get everyone’s opinions on a long awaited function on Instances that I’m sure we’d all be glad to see!

Instance:WaitForChildOfClass()

I have gone ahead and made a mock of this function but I thought it would be interesting to make a topic on this and get people’s opinions or contributions onto this topic!

function module.WaitForChildOfClass(parent: Instance, className: string, timeOut: number)
	local start = os.clock()
	timeOut = timeOut or math.huge
	repeat 
		task.wait()
	until parent:FindFirstChildOfClass(className) or os.clock - start > timeOut
	return parent:FindFirstChildOfClass(className)
end

Credits to the SmartBone Module, I was looking through the module and found this function!

This topic should goes to #resources:community-resources

1 Like

This is just a wrapper function for parent:FindFirstChildOfClass(className)