So ive been experimenting with placement systems for about 1 month now. But i recently encountered this problem while making my own placement module.. The problem is that when you change the grid to anything higer than 2 it kinda wont stick to any blocks.. Here are two videos showcasing what i mean.
Grid size 2 https://www.youtube.com/watch?v=_5UMY9dOGhQ
Grid size 4 https://www.youtube.com/watch?v=W-wpUS9rwsU
Heres the code i use to calculate the cframe:
function CAL_CF(POS, SIZE) -- // POS is the raycast position and SIZE is the current blocks size return CFrame.new( math.floor(POS.X / SIZE + 0.5) * SIZE, math.floor(POS.Y / SIZE + 0.5) * SIZE, math.floor(POS.Z / SIZE + 0.5) * SIZE ) end
Positioning the block
function placement:Enable(Name) local Block = Blocks:FindFirstChild(Name):Clone() Block.Parent = self.PLR.Character OBJ = Block MOVE = M.Move:Connect(function() local POS, SUR = RAY({self.PLR.Character}) if POS and SUR then local CF = CAL_CF(POS, self.SIZE) Block:SetPrimaryPartCFrame(CF + (SUR * (Block.PrimaryPart.Size * .5))) end end) end
My block size is 4x4x4 if you need that.