Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to clone things out of folders?

so i got a folder in my ReplicatedStorage and i want everything inside be cloned to the Workspace folder GegnerStorage but it just wont work

local enemie = game.ReplicatedStorage:FindFirstChild("Enemies"):GetChildren()
			GegnerStorage = game.workspace:WaitForChild("GegnerStorage")
			enemie:Clone().Parent = GegnerStorage
	

the error says : ServerScriptService.MAIN:68: attempt to call method 'Clone' (a nil value)

1 answer

✓ Accepted answer

When you use the :GetChildren() method, it creates a table of all the instances in the object. You will have to iterate through each of the children and clone them to GegnerStorage like so:

local enemie = game.ReplicatedStorage:FindFirstChild("Enemies"):GetChildren()
GegnerStorage = game.workspace:WaitForChild("GegnerStorage")
for _,obj in pairs(enemie) do
	obj:Clone().Parent = GegnerStorage
end

If this has solved your problem, accept it as the answer and vote up if you feel like it!

1 comment

0

Jeah it works thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.