How to see if in pairs pairs returns nothing? (repost)

im making a bike spawner system and i want to call a function if a category returns nothing, but i have no idea how to do that

local function Update(CATEGORIA)
	if Debounce or CurrentCategory == CATEGORIA then return end
	CurrentCategory = CATEGORIA
	Debounce = true
	Clear()
	for _,OBJETO in pairs(script:FindFirstChild(CATEGORIA):GetChildren()) do
		--if pairs returns nil, call a function 
		local Clonned = BIKE_MODEL:Clone()
		Clonned.Name = OBJETO.Name
		Clonned.BIKE_NAME.Text = OBJETO.Name
		Clonned.MouseButton1Click:Connect(function()
		end)
		Clonned.Parent = SCROLLFRAME
		Clonned.Viewport:SetAttribute("ItemDisplay",OBJETO.Name)
	end
	task.wait()
	Debounce = false
end

if(#script:FindFirstChild(CATEGORIA):GetChildren() <= 0) then
func()
end

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.