I am trying to create a script that can place a model after another model. This is a random model that will be chosen from a folder. It needs to be placed directly after the previous model. I tried searching on the dev forum but could not find anything useful.
local count = 1
local items = script:GetChildren()
local last = nil
local Model = items
-- setting random primary part for the model
for i=1, #Model do
if Model[i]:IsA("Model") then
ModleContain = Model[i]:GetDescendants()
if #ModleContain >0 then
for _,v in pairs(ModleContain) do
if v:IsA("BasePart") then
Model[i].PrimaryPart = v
end
end
end
end
end
-- placing models
while count < 11 do
if count == 1 then
local thing = items[math.random(1, #items)]
thing.Parent = workspace
thing:SetPrimaryPartCFrame(CFrame.new(0, 0, 0) * CFrame.Angles(0, 0, 0))
count = count + 1
last = thing
else
local thing = items[math.random(1, #items)]
thing.Parent = workspace
--what do I do here
count = count + 1
last = thing
end
end