Help with ViewportFrame

I have a part of a script where it clones an object out of a folder, into a worldmodel in a viewportFrame. and it doesnt work. The thing thats baffling me is that it works when you dont clone it. (meaning theres nothing in the folder left). Any help?

for i,tower in pairs(workspace.ViewportFrames:GetChildren()) do
	local clone = tower:Clone()
	if clone.Name == script.Parent.Parent.Name then
		clone.Parent = script.Parent.WorldModel
	end
end

We’ll need more info. Maybe it’s replication.BTW you can use ipairs instead of pairs for this, it’s faster

1 Like

“The thing thats baffling me is that it works when you dont clone it. (meaning theres nothing in the folder left).”

I can be misunderstanding you a bit, but so the issue is that when do you do clone it, the stuff in the folder is still there, but when you don’t clone it the folder is empty. That would make sense why happens because when you use :Clone() it creates a copy of that instance. My question is why would you wanne clone it?

The reason is that, I want to KEEP them in the folder for later uses, because I use them later on in a different gui.

So, I am trying to clone things out of a certain folder into a worldModel inside a viewportFrame. When I use the :Clone() function, it doesnt work, which is really weird since it works perfectly fine if I dont clone it, and just paste it into the viewport. I dont know how cloning and not cloning would make a difference when scripting, so this is really weird. I would also like to use the non-clones, for future use. Sorry if this didnt help, I tried to give as much info as possible.

Where is the folder? If it is in ServerStorage, you can not access it from the client, for example.

It was originally in workspace, then i put it in replicated storage saw that the animations wouldnt load if i put it in the viewportFrame. I’m not so sure on how to fix it.

But why not put it in replicated storage and clone it into the viewport frame?

It works, but not while cloning, and the animation script doesnt work.