How do I make a building grid place a block that is a different size?

Attempt to call a nill value.

local BlockCFrame = CFrame.lookat(BlockPosition, BlockPosition + raycastResult.Normal)

CFrame.lookAt sorry - this is for extra words

1 Like

Seems like it only works with blocks that are 1x1

When I try to place a 1x3 it just, doesn’t place.

No errors, it just doesn’t exist. I checked workspace

Can I please have the context to this problem, like the code or the place file with the building system? It’s very hard to try and solve a problem when replies are so spaced out and I have very little code to work off.

Sorry, I was using the code from

I always check this late at night, so I have a hard time thinking.

That’s fine, I will sit down in an hour or two and try and code a solution for this.

Ok, I got a chance to sit down and code this solution out and this is what I came up with.
MultiSizeBlockPlacement.rbxl (31.1 KB)

The solution shows the position the box will be placed in relative to the mouse. I did not code block placement as I just wanted the basic algorithm. You will also have to account for some clipping cases using GetPartBoundsInBox.
This solution only accounts for the client-side so you will have to figure out server-side stuff.

To change the size of the block find the Vector3Value in the workspace named BlockSize and set it to your liking to play around. The unit block is 4,4,4 as that is the size of the default Roblox grid pattern. I also added rotation, but it does not have user input (you will have to code that). It can be changed at the top of the BlockPlacement Module under the name rotation(remember it’s in radians so use math.rad).

I hope this solution helps you out and you are able to implement it into your game accordingly.

2 Likes

Hi, I was implementing your solution and I cannot seem to fix this error…

invalid argument #1 (CFrame expected, got Vector3)

Here is line 42

local blockCF = originCF * CFrame.new((part.Size/2 * Vector3.new(2,2,2)) - Vector3.new(2,2,2)/2)

This is a error from implementing your code. But your code works great in the world you sent me!

I found the answer to the problem. OriginCF is a Vector3

But now idk why its a vector3

Here is the line:

local originCF = CFrame.lookAt(blockOrigin, blockOrigin + raycastResult.Normal) * CFrame.Angles(-math.pi/2,0,0) * orient

Tysm for helping me btw :slight_smile:

Does the solution work for you now? Sorry I couldn’t help I was asleep.

1 Like

Please read my latest post…

:slight_smile:

What is the type of the orient variable? If you are using a vector rotation it won’t work. You have to use CFrame.Angles.

image
A CFrame * Vector3 returns a vector so you have to use CFrame.Angles

Ah, makes sense. It is a vector3! Does Cframe.Angles(Vector3) work?

NVM read docs

Testing it out now :slight_smile:

I don’t understand what happening?

The blocks seem to not be going where I click, and they are also curved…

No errors on my end.
Like UMMMMMM…
image

Alright, I am going to just give up on this.
image

Any ideas of how @rickje139 and @madattak manages to do this (Well kinda) in Plane Crazy?

Rick it would mean a lot if you helped me here

Are you using radians for the rotation?

local r1 = CFrame.Angles(90,0,0)
--is not the same as
local r2 = CFrame.Angles(math.rad(90),0,0)
--r2 results in a rotation of 90 degrees around the x axis, r1 results in 90 * 180/pi degrees around x axis

CFrame.Angles is Euler Angle rotation
Here are some videos explaining Euler Angles and radians

The second one is more trigonometry, but it has a good explanation of radians at the start.

Also can I please see what you are using as the rotation variable?

Well Orient = The orientation about what I would like to have the block (Which works fine)

Also I will try math.rad

Also how can I implement this? I am very new to these things… (Also tysm for all of these demonstrations!)

I made a new edit to the original place file I summited. I made the selection box show its face name and also added a simple rotation function.

e to rotate 90 degrees of x axis
r to rotate 90 degrees on y axis
t to rotate 90 degrees on z axis

to see the parts axis select the part with the move tool
MultiSizeBlockPlacement.rbxl (31.5 KB)

The rotation function works by multiplying the current rotation variable by a new CFrame.Angles with a rotation of math.rad(90) on the respective axis.

forgot to mention, the red line is x axis, blue is z and green is y

1 Like

Alright! This matches what I have for my rotating! Will check it out after finishing working for one of my clients :slight_smile: