local s={}local N=Instance.new("\066\105\110\100\097\098\108\101\069\118\101\110\116")function TryRemoveChildWithVerifyingIsCorrectType(N)if waitChildren[N.Name]and N:IsA(waitChildren[N.Name])then waitChildren[N.Name]=nil s[N.Name]=N numChildrenRemaining=numChildrenRemaining-1 end end for s,N in pairs(EventFolder:GetChildren())do TryRemoveChildWithVerifyingIsCorrectType(N)end if numChildrenRemaining>0 then local s=EventFolder.ChildAdded:connect(function(s)TryRemoveChildWithVerifyingIsCorrectType(s)if numChildrenRemaining<1 then N:Fire()end end)N.Event:Wait()s:disconnect()N:Destroy()end EventFolder=s
-- waitChildren/EventFolder does not contain all the remote events, because the server version could be older than the client version.
-- In that case it would not create the new events.
-- These events are accessed directly from DefaultChatSystemChatEvents

local useEvents = {}

local FoundAllEventsEvent = Instance.new("BindableEvent")

function TryRemoveChildWithVerifyingIsCorrectType(child)
	if waitChildren[child.Name] and child:IsA(waitChildren[child.Name]) then
		waitChildren[child.Name] = nil
		useEvents[child.Name] = child
		numChildrenRemaining = numChildrenRemaining - 1
	end
end

for i, child in pairs(EventFolder:GetChildren()) do
	TryRemoveChildWithVerifyingIsCorrectType(child)
end

if numChildrenRemaining > 0 then
	local con = EventFolder.ChildAdded:connect(function(child)
		TryRemoveChildWithVerifyingIsCorrectType(child)
		if numChildrenRemaining < 1 then
			FoundAllEventsEvent:Fire()
		end
	end)

	FoundAllEventsEvent.Event:Wait()
	con:disconnect()

	FoundAllEventsEvent:Destroy()
end

EventFolder = useEvents
