So currently I am working on a simple map system and am using clone() to replicate a model multiple times to be setup on the map. But it seems tedious to have to clone the model multiple times and set a name to it as well. Is there a way to setup models and be able to call them back later without having to set them up myself?
This is what i'm currently doing
local fenceCloneA = terrain_list["TopFence"]:Clone() local fenceCloneB = terrain_list["TopFence"]:Clone() local fenceCloneC = terrain_list["TopFence"]:Clone() local fenceCloneD = terrain_list["TopFence"]:Clone() local fenceCloneE = terrain_list["TopFence"]:Clone() local fenceCloneF = terrain_list["TopFence"]:Clone() fenceCloneA.Parent = workspace fenceCloneB.Parent = workspace fenceCloneC.Parent = workspace fenceCloneD.Parent = workspace fenceCloneE.Parent = workspace fenceCloneF.Parent = workspace
Is there an easier way to be able to clone these and be able to look back at them later if needed?
local function clone_something(thing, howmanytimes) local things_tab = {} for i = 1, howmanytimes do table.insert(things_tab, thing:Clone()) end return things_tab end local things = clone_something(terrain_list["TopFence"], 3) for i,v in pairs(things) do v.Parent = workspace end
Put them in a folder. That way, you only have to clone one folder.