Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to clone things out of folders?

Asked by 7 years ago

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

Log in to vote
1
Answered by 7 years ago

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!

0
Jeah it works thanks! Paintertable 171 — 7y
Ad

Answer this question