For some reason the when the script below runs, my dropper model and my door part switch places. I can't figure out why for the life of me. The door shouldn't even be able to get or use the dropper position. The objects I'm cloning are in the same exact hierarchy as the original plot, so I don't see that being a reason. Any insight as to how this works would be greatly appreciated.
game.Players.PlayerRemoving:connect(function(player)
if(player == Owner) then
local doorClone = game.workspace.cloneParts.GetOwner:Clone()
doorClone.Parent = script.Parent.Parent.Parent
for index, child in ipairs(script.Parent.Parent:GetChildren()) do
childOrig[index] = child
if (childOrig[index]:IsA("Part")) then
childOrigPos[index] = childOrig[index].Position
elseif (childOrig[index]:IsA("Model")) then
childOrigPos[index] = childOrig[index]:GetModelCFrame().p
end
childOrig[index]:Destroy()
end
for index, cloned in ipairs(doorClone:GetChildren()) do
childClone[index] = cloned
if (childClone[index]:IsA("Part")) then
childClone[index].Position = childOrigPos[index]
elseif (childClone[index]:IsA("Model")) then
childClone[index]:MoveTo(childOrigPos[index])
end
end
GetOwner:Destroy()
print('cloned')
end
end)

8 comments
i thought setting the table at index to equal child would rectify that, but i'll try it out
oh wait, i see what you're saying, nevermind
I get an error when I switch out index with child, and I also noticed this only happens when I start searching for a model. When I take out the dropper model and add in a bunch of random parts they always spawn that the correct locations.
I'll look at this more carefully to see if there's something else
thanks a bunch
Looking at it, I don't know how to rewrite it without a lot more information. I wrote my thoughts on what a solution might look like
it doesn't seem very efficient to go through and index every child of every model, duplicate it, move it, and put it back into a model
I ended up going the wrong direction with it, there was no reason to index both original and cloned. All I had to do was index the clone and compare that to the original with (FindFirstChild:childClone[index].Name). That way I can get the position, delete the original, and spawn the clone at that position.