Grid Placement System

I am trying to make a grid placement system, but I am not sure how I could do this. Could anybody help me? (I am not looking for code, but on HOW I could write the code for this system myself)

Thanks!

Here’s a great article about creating a robust placement system:

2 Likes

you could try UiGridLayout, see if its what you’re looking for. it was a solution for me

1 Like

Thanks a lot, I’ll check it out!

I’ll try it out, thanks. Also is it on the Developer Page?

yeah here UIGridLayout | Roblox Creator Documentation

1 Like

oh okay, thanks a lot for the help!

1 Like

What exactly are you looking for here? Grid placement like building voxels in the workspace or organizing GUI into a grid-like fashion?

1 Like

I am looking for a grid placement system similar to the one in Roblox Bedwars.

I have looked at the article, and it helped a lot. But I have one issue though, it is that I am trying to make a placement system similar to the Roblox Bedwars Game(game link here), the article helped me understand a lot more about grid systems, but how would I be able to make it where you could place blocks anywhere across the map and over the void or where nothing is under the block being placed? (Sorry if the article said anything about it and I missed it)

Thanks!

If all of the blocks are the same size, you can try using raycasts. Cast a ray from the player’s camera to the player’s cursor position (Mouse.Hit); gather information from the RaycastResult and use the surface normal to offset the block by exactly one voxel.

To simplify:

  • You use raycast to identify the block the player is looking at.
  • You use the surface normal to identify which side of the block the player is looking at.
  • Using the surface normal (which is a Vector3), you can calculate the position of the placed block.
2 Likes

Oh okay thanks, that helps a lot. I do have all the blocks at the same size, but if they were in a model, would it still work? (Sorry, I am still pretty new to coding)

You want to make sure that the raycast picks up the voxel itself and not some of the individual parts in the model. For detailed blocks like those, you can try encasing them in an invisible cube which acts like the voxel.

1 Like

Okay, thanks for the help, I’ll try writing this code and if I have anymore questions I’ll come back and ask.

I found this thread which can help:

1 Like

I’ll check it out, thanks for all the help!