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.
Also, just ask me if you want some code, although it shouldn’t be relevant here.
Have you tried maybe like an attachment or maybe putting the part on an ignore list?
Let me try this, sounds very promising
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
How would I do this? sdfsdfsdfsdf
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?
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?)
Try using Region3s. I personally haven’t used them before but from what I know, they seem pretty useful.
OR
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)
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.
Create a region with Region3 using the CFrame and Size properties.
Here is the documentation for it.
This post should also been helpful:
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?
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.