I made a building system but it wont place correctly. I used :MoveTo() so it would stand at ground level, but I’m wondering if there is a way for the 2 walls pass through each other but not through the ground
I tried turning off collisions but then I cant get them back on, Is there anything I could do with CanQuery or CanTouch?
local PosX, PosY, PosZ
local Grid = 1
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local UIS = game:GetService("UserInputService")
local Part = game.ReplicatedStorage.Wall
local function Snap(posy)
PosX = math.floor(mouse.Hit.X / Grid + 0.5) * Grid -- Snaps
PosY = 0
PosZ = math.floor(mouse.Hit.Z / Grid + 0.5) * Grid -- Snaps
end
local function Move()
Part.Parent = game.Workspace
mouse.TargetFilter = Part
Snap()
Part:MoveTo(Vector3.new(PosX, PosY, PosZ))
end
mouse.Move:Connect(Move)
UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.R then
local rotation = CFrame.Angles(0, math.rad(90), 0)
local modelCFrame = Part:GetPrimaryPartCFrame()
Part:SetPrimaryPartCFrame(modelCFrame * rotation)
end
end)
mouse.Button1Down:Connect(function()
local newpos = Vector3.new(PosX, Part.Base.Position.Y - 1, PosZ)
for i,v in pairs(Part:GetChildren()) do
if v:IsA("Part") then
v.CanCollide = false
end
end
local newpart = Part:Clone()
newpart.Parent = game.Workspace
newpart:MoveTo(newpos)
for i,v in pairs(Part:GetChildren()) do
if v:IsA("Part") then
v.CanCollide = true
end
end
for i,v in pairs(newpart:GetChildren()) do
if v:IsA("Part") then
v.CanCollide = true
end
end
end)