Hello!
So basically, I am trying to make a placement system. It works decently, however the item’s preview seems to be messing with where it’s going to be placed. How can I ignore this item?
Example, when moving the cursor away from me, the item preview only moves when the cursor goes off of the wall itself.
Here’s a snippet of my code which basically determines what goes where:
if not model.PrimaryPart then
model.PrimaryPart = model:FindFirstChild('BoundingBox')
end
local function SnapTo(num, inc)
return math.round(num / inc) * inc
end
for i,v in pairs(model:GetDescendants()) do
if v:IsA('BasePart') then
v.CanCollide = false
if v.Name ~= 'BoundingBox' then
v.Transparency = 0.5
else
v.Transparency = 1
end
end
end
local gridPart = workspace.Plot
local placementPosWorld = mouse.Hit.Position
local gridNodeSize = module.GridSize
local s,e = pcall(function()
model.Parent = gridPart
end)
if not s then return end
local yPos = gridPart.Size + (gridPart.CFrame.UpVector * (gridPart.Size.Y / 2))
model:SetPrimaryPartCFrame(CFrame.new(SnapTo(mouse.Hit.Position.X, module.GridSize), 0, SnapTo(mouse.Hit.Position.Z, module.GridSize)))
if rotation ~= 0 then
model:SetPrimaryPartCFrame(model.PrimaryPart.CFrame * CFrame.Angles(0, math.pi / 2 * rotation, 0))
end
return model