Way to make a region without the use of a part

Hello, I am making a building system, and I want the player to be able to place anything within a region, meaning that you can place stuff on top of each other. The way I was doing it before was making sure that the place they are placing it on was the platform, but this doesn’t allow the player to place stuff on each other. So, is there a way to make a region, that the script can detect and that is modular (meaning i can add more regions easily without having to check for a certain position it is in via Vector3.new())? Also, I can’t use a part because then the player can place it in the air since its detecting the part.

3 Likes

Also, just ask me if you want some code, although it shouldn’t be relevant here.

1 Like

Have you tried maybe like an attachment or maybe putting the part on an ignore list?

1 Like

Let me try this, sounds very promising

1 Like

I guess that you should make a raycast that goes under the part you want to place,
make sure it finds part under it or something that you are able to place on idk

3 Likes

How would I do this? sdfsdfsdfsdf

1 Like
local newRaycastResult =workspace:Raycast(placeHolder.PrimaryPart.Position,placeHolder.PrimaryPart.CFrame.UpVector *-100,params)

Right now, I am doing it like this, but it doesn’t seem to work. Any help?

2 Likes

Also, its getting the lowest part, so is there anyway to get all of the instances to ray is touching and just check if its touching the certain part? (I guess I could loop through every single thing in the game, but that would be bad practice, is there anyway better to do this?)

2 Likes

Try using Region3s. I personally haven’t used them before but from what I know, they seem pretty useful.

Region3 Documentation

OR

Region3 helpful DevForum post

1 Like

This should help you out:

local part = game:GetService("Workspace").test


function CreateVisualRayPart()
	local part = Instance.new("Part", workspace)
	part.Anchored = true
	part.CanCollide = false
	part.Color = Color3.fromRGB(255,0,0)

	return part
end


spawn(function()
	while wait(1) do
		local result = workspace:Raycast(part.Position, (part.Position * Vector3.new(0,-0.1,0)).unit)
		if result then
			print("part found under")
			local rayPart = CreateVisualRayPart()
			rayPart.Size = Vector3.new(2, 2, (part.Position - result.Position).Magnitude)
			rayPart.CFrame = CFrame.new((part.Position + result.Position)/2, result.Position)
		else
			print("can't place object, part didn't found")
		end
	end
end)
1 Like

Yes, but this doesn’t solve my issue. I am trying to make the raycast go through everything until it reaches the placing part, and if it does that, I want it to be able to place. And if that part ends up not being there, then I don’t want it to place, if that makes sense.

As for this, I am going to have multiple plots, so making a different region for each one would be inefficient, and if I were to add more plots, I want to be able to do so easily.

1 Like

Create a region with Region3 using the CFrame and Size properties.

Here is the documentation for it.

This post should also been helpful:

2 Likes

As I said, I don’t want to create code for each different plot if I don’t have to, so, is there a way to make this modular, and if not, is there a different method?

1 Like

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