How can I detect what face of a part a player clicks?

I’m making a minecraft-like building system. and so far I have only made it possible to create a part on top of the part you clicked.

my problem is that I have no idea how I can detect what side of the block I clicked, and place the block relative to that.

I’ve heard you need to cast a ray onto the block from your camera, but I’m not sure what to do after that.

thanks!

I think this could be what you want?

I haven’t read much on this, but you could potentially combine this with UserInputService as well to detect when a player clicks to check its target surface

1 Like

Just to mention @JackscarIitt’s comment is a much simpler way of doing that.
You can use Ray-Casting and do:

function module:CreatePartAtPosition(vectorPos, normalVector) -- // vectorPos is rayCastResult.Position and normalVector is rayCastResult.Normal
	local part = Instance.new("Part", workspace.Decals)
	part.Transparency = 1
	part.Anchored = true
	part.CanCollide = not part.CanCollide
	part.CFrame = CFrame.new(vectorPos, vectorPos + normalVector)

Note: This is a part of a code I made for a spray tool.

It doesn’t work for grid-building

Sup, maybe this post has answers and further, detailed explanations of problem you are facing. (Too long for me to read and pull out the juicy info for you xd)