I have tried quite a few methods, I am trying to get the area between multiple parts so the item I place down can only be placed n that area, and not on the outside of that area.
Here is an image of the area: pasteboard.co/HVrdQ2a.png
local m = {}
-- Priority Variables
local uis = game:GetService("UserInputService")
local runService = game:GetService("RunService")
local rs = game:GetService("ReplicatedStorage")
local furniture = rs["Furniture"]
local remotes = rs["Remotes"]
local confrimPlacement = remotes["ConfirmPlacement"]
-- Secondary Variables
local studio = workspace:WaitForChild("Harbour Studio")
local studioFurniture = studio["Furniture"]
local owner = studio["Owner"]
--Model Placement Varibles
local plr
local mouse
local itemsFrame
local finished
local node
local preview
local pp
local selection
local canPlace
local rot = 0
local placing
function previewItem()
if (placing == false) then
return
end
local allNodes = studio["Nodes"]:GetChildren()
for _,n in next, allNodes do
node = n
end
if (owner.Value == plr.Name) and (pp.Position - node.Size).magnitude < (node.Position - pp.Size).magnitude then
selection.Color3 = Color3.fromRGB(0,155,0)
canPlace = true
else
selection.Color3 = Color3.fromRGB(155,0,0)
canPlace = false
end
local angle = CFrame.fromEulerAnglesXYZ(0,math.rad(rot),0)
local vec = Vector3.new(0,preview.PrimaryPart.Size.Y/2,0)
local cf = CFrame.new(mouse.Hit.p+vec)*angle
preview:SetPrimaryPartCFrame(cf)
end
function m.start(p, modelName, frame, fin)
plr = p
itemsFrame = frame
finished = fin
itemsFrame.Visible = false
finished.Visible = false
mouse = plr:GetMouse()
--node = studio["Node1"]
preview = furniture[modelName]:Clone()
preview.Parent = workspace
pp = preview.PrimaryPart
selection = Instance.new("SelectionBox", workspace)
selection.LineThickness = 0.05
selection.Adornee = pp
mouse.TargetFilter = preview
for i,p in next, preview:GetChildren() do
if not (p.Name == "Hitbox") then
p.Transparency = 0.5
p.CanCollide = false
end
end
placing = true
runService.RenderStepped:Connect(previewItem)
end
function m.cancel()
if (preview) then
placing = false
preview:Destroy()
selection:Destroy()
plr = nil
mouse = nil
node = nil
mag = nil
preview = nil
pp = nil
selection = nil
canPlace = nil
rot = 0
itemsFrame.Visible = true
itemsFrame = nil
finished.Visible = true
finished = nil
end
end
function m.rotate()
if (preview) then
rot = rot +1
preview:SetPrimaryPartCFrame(preview.PrimaryPart.CFrame*CFrame.fromEulerAnglesXYZ(0,math.rad(rot),0))
end
end
function m.place()
if (preview) and (placing == true) and (canPlace == true) then
placing = false
confrimPlacement:FireServer(preview.Name, preview:GetPrimaryPartCFrame())
end
end
return m

5 comments
magnitude
I don't really know how to use it
maybe region3
Hey -- it seems the other answers haven't looked at the image you provided. Are you looking for surface area or complex volume? (surface area or cubic studs inside of your highlighted area)
Not sure, I just want to be able to check to see if the object I am placing is between the area I have highlighted.