Gui weird problems

Hey fellow programmers!

I’ve encountered a bug in my game that i don’t know why happens…

When i load into a game i have my table loaded, and everything loads in perfectly except one thing It’s supposed to show my pets (they’re from a string value) but they aren’t there. When i try to get another pet somehow everything from the data pops out if this is confusing look at the demonstration down below

In short the egg gives you 1 pet, and when i opened my inventory it shows nothing, but when i open an egg and receive 1 pet, all of the others load

Here are my gui/datastore scripts

-- Data store (it works perfectly fine)
game.Players.PlayerAdded:Connect(function(plr)
	
	local data = ds1:GetAsync(plr.UserId.."-pet")
	
	if data then
		
		for i, petName in pairs(data) do
			if game.ReplicatedStorage:WaitForChild("Pets"):FindFirstChild(petName) then
				local stringValue = Instance.new("StringValue")
				stringValue.Name = petName
				stringValue.Parent = plr.PetInventory
			end	
		end
		
		game.ReplicatedStorage.SendData:FireClient(plr,data)
	else
		print("No data found, must be a new player or something happened to the data!")	
	end

-- Local script (on Client event)
game.ReplicatedStorage.SendData.OnClientEvent:Connect(function(petNames)
	
	for i, petName in pairs(petNames) do
		
		if game.ReplicatedStorage.Pets:FindFirstChild(petName) then
			
			local newTemplate = GuiClient.addToFrame(game.ReplicatedStorage.Pets:FindFirstChild(petName))
			
		end	
			
	end
	
end)

-- The module script
GuiClient.addToFrame = function(pet)
	
	local newTemplate = template:Clone()
	newTemplate.Name = pet.Name
	newTemplate.PetName.Text = pet.Name
	newTemplate.Parent = scrollingFrame
	
	local newPet = pet:Clone()
	newPet.Parent = newTemplate.ViewportFrame
	
	local camera = Instance.new("Camera")
	camera.CFrame = CFrame.new(newPet.PrimaryPart.Position + (newPet.PrimaryPart.CFrame.LookVector * 2.5), newPet.PrimaryPart.Position)
	camera.Parent = newTemplate.ViewportFrame
	
	newTemplate.ViewportFrame.CurrentCamera = camera
	
	return newTemplate
end

Any ideas on what might be going on? Thanks in advance!

If you got confused by anything ask me in the comments!

Is the visible property set to true?

Yeah, thus i never set it anywhere to be false

I updated the script so there’s no module at all

game.ReplicatedStorage.SendData.OnClientEvent:Connect(function(petNames)
	
	for i, petName in pairs(petNames) do
		
		if game.ReplicatedStorage.Pets:FindFirstChild(petName) then
			
			addToFrame(game.ReplicatedStorage.Pets:FindFirstChild(petName))
			
		end	
			
	end
	
end)

-- The function

function addToFrame(pet)
	
	local newTemplate = template:Clone()
	newTemplate.Name = pet.Name
	newTemplate.PetName.Text = pet.Name
	newTemplate.Parent = scrollingFrame
	
	local newPet = pet:Clone()
	newPet.Parent = newTemplate.ViewportFrame
	
	local camera = Instance.new("Camera")
	camera.CFrame = CFrame.new(newPet.PrimaryPart.Position + (newPet.PrimaryPart.CFrame.LookVector * 2.5), newPet.PrimaryPart.Position)
	camera.Parent = newTemplate.ViewportFrame
	
	newTemplate.ViewportFrame.CurrentCamera = camera
	
end

If the template’s visible property is set to false, then you’d need to set your template clone’s visible property to true.

Try adding newTemplate.Visible = true after you clone it.

Still nothing