Script only cloning one frame instead of the calculated

The title is saying everything, let’s take an example that the calculated pets are 8, well, it is only cloning one instead of those 8, here is the script:

for _, Pet in pairs(ShopItems:GetChildren()) do
    local Item = PrefabItem:Clone()
	local PetData = PetsData[Pet.Name]
	Item.Parent = Frame
    Item.Name = Pet.Name
    Item.Description.Text = PetData["Info"]
    Item.Price.Text = PetData["Cost"]
    Item.Picture.Image = "rbxassetid://" .. PetData["ImageId"]

    Item.Buy.MouseButton1Down:Connect(function()
		local HasBought = Item:FindFirstChild("HasBought")
		game.ReplicatedStorage.PetAdd:FireServer(Item.Name)
		print(player.Name.." sent a request to the server to buy something!")
    end)
	wait(0.2)
end

There’s any reason of why that’s happening i hope you help me! Thanks :+1:

1 Like

To debug something, put print commands to see if all the prints went through because you didn’t provide sufficient info about the problem

I set a print here:

    Item.Buy.MouseButton1Down:Connect(function()
		local HasBought = Item:FindFirstChild("HasBought")
		game.ReplicatedStorage.PetAdd:FireServer(Item.Name)
		print(player.Name.." sent a request to the server to buy something!")
    end)
    print("Stupid print example")

And it didn’t print.

The only thing I suspect is that there was an error on that third line, and when it errors, the that chunk of the script breaks