You should have gotten errors with this code. A vector3 takes float values as the X, Y, Z values but you use the integer N value.
Try changing the SpawnProp line to MaybeProp := SpawnProp(PropAssetRef, vector3{X:=N * 1.0, Y:=N * 1.0, Z:=0.0}, IdentityRotation()) and see if that works.
The way the type option MaybeProp? works is that if the prop fails to spawn, you can’t assign it to the Prop value and the if fails. That way, it returns void instead of creative_prop. Since your spawnprop is probably failing due to the int values instead of float values, the if-statement fails and returns void.
I also have a question, what does the (0) do at the end of your SpawnProp line?
As to your issue, I haven’t initialized variables that way enough to see the issue. My guess would be that because of the option type creative_prop? if-statement, it doesn’t work.
For example, if you create a function that returns a creative_prop like this
That also doesn’t work because the function isn’t sure that it ALWAYS returns a creative_prop. The same principle applies to your issue. Since it’s not all paths that lead to a creative_prop being returned, it fails and sets the return type to void as a failsafe.
The problem with your original code is that if without an else does not yield a useful value. if(a) then b else c yields b or c, but if(a) then b is only useful for its side effects.
The for is just evaluating the body expression for each possible value in the domain, and creating an array containing the yielded values. The body expression in this case was a block with multiple subexpressions, so it uses the value yielded by the final subexpression in the block. Your if-without-else does not yield a useful value, so it creates an array of useless values.
As others have pointed out, if don’t want some iteration of the for to produce an element in the output array, then you need to make the domain of the for (the part in parentheses) fail for that iteration.