I am trying to make a placement system but when i try to place a block onto another part it clips into it. Does anyone know how to fix this?
local player = game.Players.LocalPlayer
local character =player.CharacterAdded or player.Character
local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local camera = workspace.CurrentCamera
local placeEvent = game.ReplicatedStorage:WaitForChild("PlaceEvent")
local block = game.Workspace:WaitForChild("Part")
local function getMousePoint(X,Y)
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {block,}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
local camRay = camera:ScreenPointToRay(X,Y)
local raycastResults = workspace:Raycast(camRay.Origin,camRay.Direction * 2048, raycastParams)
if not raycastResults then return nil end
return raycastResults.Instance, raycastResults.Position
end
UIS.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
local mouseLocation = UIS:GetMouseLocation()
local target, position = getMousePoint(mouseLocation.X, mouseLocation.Y)
if target and position then
end
end
end)
RunService.RenderStepped:Connect(function()
local mouseLocation = UIS:GetMouseLocation()
local target,position = getMousePoint(mouseLocation.X,mouseLocation.Y)
if target and position then
block.CFrame = CFrame.new(position)
end
end)