what this script is made to do is it there's a function that sets a random position for a part and gets the part name, then it clones the part, then starts setting the clone value / variable to a clone of the previous clone and sets the position to random it repeats that 20 times before stopping, but it doesn't work, for some reason it only changes the position for the current part (not a clone) if anyone has some information on how to fix it or (even better) an actual working script, i would greatly appreciate it
local function random(position, who)
for _, child in ipairs(script.Parent.poggy:GetChildren()) do
if child.Name == who then
child.Position = position
end
end
end
local area = 354
local baseplate_position=Vector3.new(177.753, 861.364, -402.773)
while true do
local clone = script.Parent.poggy.Smiler:Clone()
random(Vector3.new(math.random(-area/2,area/2),1,math.random(-area/2,area/2))+baseplate_position, clone.Name)
for i = 1, 20 do
clone = clone:Clone()
random(Vector3.new(math.random(-area/2,area/2),1,math.random(-area/2,area/2))+baseplate_position, clone.Name)
end
break
end
