Hello! I've been recently working in a block placement system using mouse.Hit, and I'm stuck with a problem; I don't know how to make the blocks not go through others.
This is the code I have:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local runservice = game:GetService("RunService")
local ts = game:GetService("TweenService")
local part = Instance.new("Part", workspace)
part.Size = Vector3.new(4,4,4)
mouse.TargetFilter = part
part.CanCollide = false
part.Anchored = true
part.Material = Enum.Material.SmoothPlastic
mouse.Move:Connect(function()
local target = mouse.Hit
local Ypart = mouse.Target
local face = mouse.TargetSurface
if target and Ypart then
ts:Create(part, TweenInfo.new(0.1, Enum.EasingStyle.Sine), {Position=Vector3.new(math.floor(target.Position.X + 0.5) - part.Size.X/2, math.floor(target.Position.Y) + part.Size.Y/2, math.floor(target.Position.Z + 0.5)- part.Size.Z/2)}):Play()
end
end)
I don't really know how to explain, but when you try to place a block on a wall, the block goes inside the wall and it does z-fighting. The thing I'm trying to do is making the blocks not collide with each other while being placed.
