Creating a Grid with Dynamic Points

a grid of points within a part with a factor of 4 (will change occasionally). However If the factor + the current amount would be added is bigger than the actual size of the part it will go to the edge of the part like the example below (in 2 dimensions for simplicity )

Because of how for loops work in roblox they don’t go over the given amount, for example

for i = 0,10,3 do
     print(i)
end

That piece of code won’t go above 10 (as it’s supposed to), But it won’t hit 10 either. It will stop at 9.
I’ve tried brute forcing it but it won’t always work as intended. Thanks for helping!

You could check if “i” is a mod of 3, else run other code. Example:

for i = 0, 10 do
	if i % 3 == 0 then
		-- this will run for 3,6 and 9.
	else
		-- this will run for 0,1,2,4,5,7,8 and 10.
	end
end

this will allow you to run code after 9 but no more than 10.

1 Like

wow… I spent hours trying to figure this out… and it gets solved in 2 sentences. Thanks tho! :happy1: