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

[SOLVED] Copy all items in folder multiple times?

Asked by 5 years ago
Edited by RubenKan 5 years ago

So right now there are only 3 items in the folder ( tools ). and i want that they get randomly copied and inserted into the workspace. but it just get the only 3 items from my folder inserted into the workspace and after that, the main folder where they were stored is empty.

        local items = game.ReplicatedStorage.Items:GetChildren()
        local amount = math.random(10,30)

        for i = 1,amount do
            local randomitems =  items[math.random(#items)]
            local itemspawn = newmap.Items:GetChildren()
            local randomspawn = itemspawn[math.random(#itemspawn)]:clone()
                randomitems.Parent = game.Workspace:WaitForChild("Items")
                randomitems.Handle.CFrame = randomspawn.CFrame
        end

The amount is that it randomly chooses how many items are getting copied into workspace. it should normaly be between 10 and 30.

Any help? If you have questions ask me down below.

Answer this question