Just wondering if there’s a more efficient way to generate 100 parts into the workspace when you click a ScreenGUI button
Just beginning scripting so feedback appreciated!
function Part()
Instance.new("Part",workspace)
end
numParts = 0
function clicked()
numParts = 0
while true do
Part()
numParts = numParts + 1
if numParts == 100 then
break
end
end
end
script.parent.MouseButton1Click:Connect(clicked)
@Halalaluyafail3 If you reread the thread you posted, it says to avoid using it with parent argument when setting other properties immediately afterwards. If the only property you’re going to set is parent, it’s perfectly fine to use the second argument.
@main post
Instead of using a while loop, you can use a numeric for loop that will automatically add to the variable for you. Example:
the for loop helped a lot instead of using a while loop, and the code is a lot more clean as there isn’t the function checking for if there is 100 parts because thats already being done in the for loop. Thanks!