When cloning an UI object, it's descendants are missing

Hi! I would like to clone an already made UI object located in the ServerStorage. But everytime I try to clone it and modify it’s properties. I get a “no found” error. When checking the explorer I’ve just noticed the object has all of it’s descendants missing.

The objects are all marked as archivable, so I don’t know if I’m missing something.

Here is the complete code and some screenshots.


--DOCS
--https://devforum.roblox.com/t/what-are-tuples/550711


--Services
Players = game:GetService("Players")
ServerStorage = game:GetService("ServerStorage")
ServerScriptService = game:GetService("ServerScriptService")
CollectionService = game:GetService("CollectionService")


--Modules
DatabaseModule = require(ServerScriptService.DatabaseModule)


--References
playerDonationFrameTemplate = ServerStorage.UI.PlayerDonationFrame
playersScrollingFrame = script.Parent.ScrollingFrame


--Variables
topDonatorPlayers = {}
topDonatorRobux = {}


--Refresh the UI deleting old frame and replacing them with new ones with updated info
function RefreshUI()

	--Refresh Info
	topDonatorPlayers, topDonatorRobux = DatabaseModule.GetTopDonators()

	--Destroy all the old frames
	local oldFrames = CollectionService:GetTagged("PlayerDonationFrameUI")

	for i, frame in ipairs(oldFrames) do
		frame:Destroy()
	end

	--Create new frames
	for i, donatorId in ipairs(topDonatorPlayers) do

		local newFrame = playerDonationFrameTemplate:Clone()
		newFrame.Parent = playersScrollingFrame
		newFrame.PlayerText.Text = Players:GetPlayerByUserId(donatorId).Name
		newFrame.RobuxText.Text = topDonatorRobux(i)
		newFrame.PlayerImage.Image = Players:GetUserThumbnailAsync(donatorId, Enum.ThumbnailType.HeadShot)
	end

end


while true do
	
	wait(3)
	
	RefreshUI()
	
	wait(8)
end

How it should look


image

How it actually looks after cloned


As you can see all the childs of the object are missing.

Here’s the error:

06:47:59.901  PlayerText is not a valid member of Frame "Workspace.GlobalBillboard.DonationsBoard.SurfaceGui.ParentFrame.PlayersFrame.ScrollingFrame.PlayerDonationFrame"  -  Server - TopDonatorsLogic:44
  06:47:59.901  Stack Begin  -  Studio
  06:47:59.901  Script 'Workspace.GlobalBillboard.DonationsBoard.SurfaceGui.ParentFrame.PlayersFrame.TopDonatorsLogic', Line 44 - function RefreshUI  -  Studio - TopDonatorsLogic:44
  06:47:59.901  Script 'Workspace.GlobalBillboard.DonationsBoard.SurfaceGui.ParentFrame.PlayersFrame.TopDonatorsLogic', Line 56  -  Studio - TopDonatorsLogic:56
  06:47:59.901  Stack End  -  Studio

Any help is appreciated :slightly_smiling_face:

1 Like

Have you already checked while running the game, that PlayerText is indeed in the PlayerDonationFrame?
Have you already tried to use WaitForChild on the PlayerText?

Yes, I’ve also tried the WaitForChild, and it yields infinitely.
While running the game as you can see in the screenshot, all the frame content is missing, and all it’s respective childs.

I am not sure you’re looking the right place, if it yields inf.

That’s the weird thing. The place is not bad because the parent object at least gets cloned, so the object exists.

Okey. I’ve found and fixed the error. I was getting with CollectionService all the objects tagged to be frames, so I could delete them before. This behaviour was intended to refresh the UI. But I’ve just figured out it was deleting the object to be cloned too that’s located in ServerStorage. This is the fixed code:

--DOCS
--https://devforum.roblox.com/t/what-are-tuples/550711


--HELP
--https://devforum.roblox.com/t/when-cloning-an-ui-object-its-descendants-are-missing/2059597


--Services
Players = game:GetService("Players")
ServerStorage = game:GetService("ServerStorage")
ServerScriptService = game:GetService("ServerScriptService")
CollectionService = game:GetService("CollectionService")


--Modules
DatabaseModule = require(ServerScriptService.DatabaseModule)


--References
playerDonationFrameTemplate = ServerStorage.UI.PlayerDonationFrame
playersScrollingFrame = script.Parent.ScrollingFrame


--Variables
topDonatorPlayers = {}
topDonatorRobux = {}


--Refresh the UI deleting old frame and replacing them with new ones with updated info
function RefreshUI()

	--Refresh Info
	topDonatorPlayers, topDonatorRobux = DatabaseModule.GetTopDonators()

	--Destroy all the old frames (Exclude the one in the server storage)
	local oldFrames = CollectionService:GetTagged("PlayerDonationFrameUI")

	for i, frame in ipairs(oldFrames) do
		
		if frame.Parent.Parent.Name ~= "ServerStorage" then
			frame:Destroy()	
		end
	end

	--Create new frames
	for i, donatorId in ipairs(topDonatorPlayers) do

		local newFrame = playerDonationFrameTemplate:Clone()
		newFrame.Parent = playersScrollingFrame
		newFrame.PlayerText.Text = Players:GetPlayerByUserId(donatorId).Name
		newFrame.RobuxText.Text = topDonatorRobux(i)
		newFrame.PlayerImage.Image = Players:GetUserThumbnailAsync(donatorId, Enum.ThumbnailType.HeadShot)
	end

end


while true do
	
	wait(3)
	
	RefreshUI()
	
	wait(8)
end

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