I am trying to make an placement system
but I want to parts to stack on each other, I can’t. I tried Model.PrimaryPart.Position.Y + Model.PrimaryPart.Size.Y / 2 + Model.PrimaryPart.Size.Y / 2
method and it made my block fly instead of stacking on another block.
Here is my script for placement:
local PosX
local PosY
local PosZ
local Model = (ItemsList:WaitForChild("Background"):WaitForChild("Configuration"):WaitForChild("CurrentItem").Value):Clone()
Model.Parent = workspace
local GridSize = 2
local function Snap()
PosX = math.floor(Mouse.Hit.X / GridSize + 0.5) * GridSize
PosY = Model.PrimaryPart.Position.Y + Model.PrimaryPart.Size.Y / 2 + Model.PrimaryPart.Size.Y / 2
PosZ = math.floor(Mouse.Hit.Z / GridSize + 0.5) * GridSize
--Model.PrimaryPart.Position.Y + Model.PrimaryPart.Size.Y / 2 + Model.PrimaryPart.Size.Y / 2
end
local function Movement()
Mouse.TargetFilter = Model
Snap()
Model:SetPrimaryPartCFrame(CFrame.new(PosX, PosY, PosZ))
end
Mouse.Button1Down:Connect(function()
-- do on server instead of client (just dev note, ignore that note)
local freshModel = Model:Clone()
freshModel.Parent = workspace
Mouse.TargetFilter = Model
Snap()
Model:SetPrimaryPartCFrame(CFrame.new(PosX, PosY, PosZ))
end)
Mouse.Move:Connect(Movement)
There is nothing wrong with models