How to detect what side of a part a player clicks on with player:GetMouse()

Hello!

Objective: So, im making a simple building system and I want to detect the side of a part that the player clicked, so I can place the part in this side.

For now, I have this: if a placed block is clicked, the part will be created on the top of this block, but that is not all I want.

	i.Position = mouseTarget.Position + Vector3.new(0, 2/2, 0)
	if table.find(objects, mouseTarget.Name) then
		i.Position = mouseTarget.Position + Vector3.new(0, 2, 0)
	end

I already searched for some topics about this, and:
Use surface guis with buttons in each side: Well, Im using :GetMouse for this so I dont believe that this would work, and I also think it would cause lag.
Use multiple parts for each side: This is a great idea, but I think it would cause lag and also I want something “simple”.

So, is there any way to detect which surface/side of the part was clicked, and place the block in this side? Any help is appreciated.

I think this could help quite a lot. Similar circumstances aswell.

1 Like

Thank you!
I will take a look on this and i’ll reply

Whoops, reading the thread looks like you can also use Mouse.TargetSurface. Might be simpler for your scenario, but your choice.

Oh, sure. (and sorry for the late reply)
I tried Mouse.TargetSurface.Name but it returns attempt to index nil with 'Name', what is wrong?

It’s because Mouse.TargetSurface is not a part.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.